Click here to Skip to main content
15,917,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a Scenario in which i have used ajax:TabContainer to load grid view inside User Control, on click of each tab a user control is loaded, Whats going wrong is on click of each Tab in ajax:TabContainer javascript is called as Many times as the tab is clicked.

eg: if i click tab1 the js loads 1's and if i click tab3 the js loads twice, and if i click tab1 again the js loads thrice and so on.

I found this when i had placed an alert message in js file.

Here is my code

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <asp:AsyncPostBackTrigger ControlID="btnSearch" />
                <asp:AsyncPostBackTrigger ControlID="MainTab" />
                    <asp:HiddenField ID="HiddenField1" runat="server" ClientIDMode="Static" />
                <div id="DivGridUserControl" class="DivJLGridUserControl">
                    <ajax:TabContainer ID="MainTab"  runat="server" AutoPostBack="true" ActiveTabIndex="0" CssClass="fancy fancy-green ajax__tab_header">
                        <ajax:TabPanel ID="TabStatus"  runat="server">
                            <div >
                                <uc1:JLStatus  runat="server" ID="GrvJobListStatus" />
                        <ajax:TabPanel ID="TabShip"  runat="server">
                                <uc1:JLShip  runat="server" ID="GrvJobListShip"   />
                        <ajax:TabPanel ID="TabAcct"  runat="server">
                                <uc1:JLAcct  runat="server" ID="GrvJobListAcct"  />
                        <ajax:TabPanel ID="TabMschedule"  runat="server">
                                <uc1:JLMschedule  runat="server" ID="GrvJobListJLMschedule"  />

Can some one tell how I can come out of this.

Thanks in advance.
Sreekanth Mothukuru 13-Sep-14 8:21am    
how you are loading js on each click? I see no js in this script !!
Yashwanth R 15-Sep-14 0:20am    
Actually I have a vertical menu which slides open on a image click and slides back on another image click. I have this menu in master page and have written sliding function masterpage.js; on expansion of vertical menu i need to resize the content page which holds the ajax:TabContainer, so I have the resize function called on same image button click of menu in content page js file.

If i place/call the resize function from master page js file itself the content js will not load multiple times.

Thanks for the reply.
Sreekanth Mothukuru 15-Sep-14 1:38am    
I think instead of calling resize js method on the image client (i.e., before loading the content page), you need to call the it after loading the content page (Tab container) using any of the following method server side.


Hope this helps!
Yashwanth R 15-Sep-14 3:10am    
Ya I'm calling after content page load itself, i have called even after all the master page gets loaded, but still getting the same problem.
Sreekanth Mothukuru 15-Sep-14 5:42am    
Not sure, if I'm following you. I suspect that on each click to load user control.. you are adding same JavaScript function to the master page. This could duplicate functionality. That could be the reason JavaScript loads multiple times. Try to attach the related JavaScript within the user control and not outside.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900