Click here to Skip to main content
12,292,006 members (68,611 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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

<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 17-Dec-12 22:09pm
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160518.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100