Avatar of Stanton_Roux
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;


        //TODO WORK OUT SIZE OF UL 
        // 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;
        });




    });

</script>
<div class="showCaseWrapper">
    <div class="showcaseHeading">
        <h2>
            <asp:Label ID="lblShowcase" runat="server">Showcase</asp:Label></h2>
    </div>
    <div class="clear">
    </div>
    <div class="showcasescrollbuttons">
        <div id="btnPrev">
            PREV</div>
        <div id="btnNext">
            NEXT</div>
    </div>
    <div class="clear">
    </div>
    <div class="showcaseContent">
        <div class="showcaseSlider">
            <asp:Literal ID="litContent" runat="server"></asp:Literal></div>
    </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>
            <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>
            <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>
            <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>
            <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>
            <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>
            <li id="liDigital" class="" runat="server">
                <asp:LinkButton ID="hpDigital" class="lbNav" runat="server" OnClick="hpDigital_Click"><span></span><strong>Digital</strong></asp:LinkButton>
            </li>
        </ul>
    </div>
</div>

Open in new window

ASP.NETjQuery

Avatar of undefined
Last Comment
dejaanbu

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dejaanbu

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
or
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