Avatar of Stanton_Roux
Flag for South Africa asked on

JQUERY not working after partial postback

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>

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck