Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have used Ajax Tab Container in my Page Which Has some 5 Tab Panels.
What i want in this is ,
Whenever user click on another tab i want to make sure that the current tab data is saved or not if not i want to give a user an alert to save the current tab data like yes/no.
if he clicks yes he should not go to the clicked tab panel, else he should move to next panel.


here is the code for my tab container

XML
<asp:TabContainer ID="TabContainer" runat="server" width="800px"
       ActiveTabIndex="1" >

   <asp:TabPanel ID="tabpnl1" runat="server" >
   <HeaderTemplate>
   tabpanel1
   </HeaderTemplate>
       <ContentTemplate>
           <br />
           <br />
           
           <br />
           <asp:Button ID="Btnsave" runat="server" Text="Save" />
       </ContentTemplate>
   </asp:TabPanel>
    <asp:TabPanel  ID="tabpanel2" runat="server">
   <HeaderTemplate>
   tabpanel2
   </HeaderTemplate>
   <ContentTemplate>
       <br />
       
        <br />
        <asp:Button ID="BtnSave" runat="server" Text="Save" />
   </ContentTemplate>
   </asp:TabPanel>
    <asp:TabPanel  ID="tabpanel3" runat="server">
   <HeaderTemplate>
  tabpanel3
   </HeaderTemplate>
   <ContentTemplate>
       <br />
       <br /> &nbsp;<asp:Button ID="BtnSave" runat="server" Text="Save" />
   </ContentTemplate>
   </asp:TabPanel>
    <asp:TabPanel  ID="tabpanel4" runat="server">
   <HeaderTemplate>
 tabpanel4
   </HeaderTemplate>
   <ContentTemplate>
        <br />
     
         <br />
         <asp:Button ID="Btnsave" runat="server" Text="Save" />
   </ContentTemplate>
   </asp:TabPanel>
   <asp:TabPanel  ID="tabpanel5" runat="server">
   <HeaderTemplate>
 tabpanel5
   </HeaderTemplate>
   <ContentTemplate>
        <br />
      
         <br />
         <asp:Button ID="BtnSave" runat="server" Text="Save" />
   </ContentTemplate>
   </asp:TabPanel>
   
   
   </asp:TabContainer>


How to Do this. Please Advice.
Please
Posted
Comments
pinky1810 18-Dec-12 4:30am    
Please advice how to prevent going to next tab before he save data in previous tab
Avinash_Pathak 18-Dec-12 6:24am    
hi...u can use javascript to check whether anything is changed in your current tab or not. If yes so before leaving active tab call that java script alert indicating that"There is unsaved data on this tab, you want to still move?"
By doing this your problem must be solved...I did the same thing while moving one page to another...
pinky1810 19-Dec-12 1:02am    
can u give me some example code. like where in which event i should call the java script? Please.

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