troubleshooting Question

JQUERY not working after partial postback

Avatar of Stanton_Roux
Stanton_RouxFlag for South Africa asked on
1 Comment1 Solution1125 ViewsLast Modified:
HI There

I have a user control that has some jquery code inside it.
After I do a partial postback the JQUERY code no longer works.

Is there a way to re-enable that code so that it continues to work for that usercontrol only after I do a partial postback.

I dont want to refresh the entire page again.I only want the code within the user control to continue to work.

See code below.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="showcase.ascx.cs" Inherits="Controls_showcase" %>
<script type="text/javascript">

    $(document).ready(function () {

        var step = 2;
        var current = 0;
        var maximum = $('.showcaseSlider ul li').size();
        var visible = 2;
        var speed = 2000;
        var liSize = 210;
        var carousel_height = 600;

        // var ulSize = liSize * maximum;

        var ulSize = 1000;
        var divSize = liSize * visible;


        $('.showcaseSlider ul').css("width", ulSize + "px").css("left", -(current * liSize)).css("position", "absolute");

        $('.showcaseSlider').css("visibility", "visible").css("overflow", "hidden").css("position", "relative");

        $('#btnNext').click(function () {

            if (current + step < 0 || current + step > maximum - visible) { return; }
            else {
                current = current + step;
                $('.showcaseSlider ul').animate({ left: -((liSize * current)) }, speed, null);
            return false;

        $('#btnPrev').click(function () {
            if (current - step < 0 || current - step > maximum - visible) { return; }
            else {
                current = current - step;
                $('.showcaseSlider ul').animate({ left: -((liSize * current)) }, speed, null);
            return false;


<div class="showCaseWrapper">
    <div class="showcaseHeading">
            <asp:Label ID="lblShowcase" runat="server">Showcase</asp:Label></h2>
    <div class="clear">
    <div class="showcasescrollbuttons">
        <div id="btnPrev">
        <div id="btnNext">
    <div class="clear">
    <div class="showcaseContent">
        <div class="showcaseSlider">
            <asp:Literal ID="litContent" runat="server"></asp:Literal></div>
    <div class="showcaseNav tabs">
        <ul class="nav tabs">
            <li id="liShowcase" class="selected" runat="server">
                <asp:LinkButton ID="hpShowCase" class="lbNav" runat="server" OnClick="hpShowCase_Click"><span></span><strong>Showcase</strong></asp:LinkButton>
            <li id="liDesign" class="" runat="server">
                <asp:LinkButton ID="hpDesign" class="lbNav" runat="server" OnClick="hpDesign_Click"><span></span><strong>Design</strong></asp:LinkButton>
            <li id="liOutdoor" class="" runat="server">
                <asp:LinkButton ID="hpOutdoor" class="lbNav" runat="server" OnClick="hpOutdoor_Click"><span></span><strong>Event</strong></asp:LinkButton>
            <li id="liPrint" class="" runat="server">
                <asp:LinkButton ID="hpPrint" class="lbNav" runat="server" OnClick="hpPrint_Click"><span></span><strong>Print</strong></asp:LinkButton>
            <li id="liRadio" class="" runat="server">
                <asp:LinkButton ID="hpRadio" class="lbNav" runat="server" OnClick="hpRadio_Click"><span></span><strong>Radio</strong></asp:LinkButton>
            <li id="liTV" class="" runat="server">
                <asp:LinkButton ID="hpTV" class="lbNav" runat="server" OnClick="hpTV_Click"><span></span><strong>TV</strong></asp:LinkButton>
            <li id="liDigital" class="" runat="server">
                <asp:LinkButton ID="hpDigital" class="lbNav" runat="server" OnClick="hpDigital_Click"><span></span><strong>Digital</strong></asp:LinkButton>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros