locked
TabContainer and ActiveTabChanged RRS feed

  • Question

  • User1512840900 posted

    Hi,

    i have a problem with TabContainer.

    The ActiveTabChanged server-side event doesn't fire when i click on tab.

    Is this a bug?

    Can anyone help me?

     Thanks everbody!

    Tuesday, January 30, 2007 2:56 AM

All replies

  • User-1429816726 posted
    I believe the server-side event will only fire when a postback occurs. Tabs doesn't use postbacks when simply switching between tabs. Maybe you'd like to use OnClientActiveTabChanged instead?
    Tuesday, January 30, 2007 5:19 PM
  • User1512840900 posted

    [:(]

    I ask this because I have this problem: I must load many data from database for each tab of tabcontainer. 

    So, I don't want to load all data from database only one time, but only if a user clicks on a tab.

    I think there is no solution with this event (ActiveTabChanged).

    Can you have some ideas to solve my problem with TabContainer?

    Wednesday, January 31, 2007 5:01 AM
  • User1075616431 posted
    Maybe with Webservice and pagemethods?
    Wednesday, January 31, 2007 8:45 AM
  • User-1071399013 posted
    Can you please elaborate a bit on webservice and pagemethod. I have the same problem and need to finda solution asap.
    Wednesday, January 31, 2007 9:41 AM
  • User-1071399013 posted
    Can you please elaborate a bit on webservice and pagemethod. I have the same problem and need to find a solution asap.
    Wednesday, January 31, 2007 9:41 AM
  • User-1071399013 posted

    Here is what start working for me (sure it is a temp solution but still....) Sorry for detailed instructions, but I believe in "documenting" everything to make a life easy. [:D]

     1. Change javascript function to add a custom postback:

           function ActiveTabChanged(sender, e) {
                var CurrentTab = $get('<%=CurrentTab.ClientID%>');
                CurrentTab.innerHTML = sender.get_activeTab().get_headerText();
                //add a custom postback
                 __doPostBack('Tabs', sender.get_activeTab().get_headerText());
                Highlight(CurrentTab);
            }

     2. In TabContainer add a method:

            <ajaxToolkit:TabContainer runat="server" 
            ID="Tabs" Height="450px"  
            OnClientActiveTabChanged="ActiveTabChanged"  
             OnActiveTabChanged="ActiveTabChangedServer"
             >

     3. Inside of TabPanels add an UpdatePanel wrapper and dont forget about trigger!

                   <asp:UpdatePanel 
                     ID="upTab_List" 
                     runat="server" 
                     UpdateMode="Conditional">
                        <ContentTemplate>
    
                        Datagrid, dynamic content etc
                        </ContentTemplate>
    
                        <Triggers>
                            <asp:AsyncPostBackTrigger 
                                  ControlID="Tabs" 
                                  EventName="ActiveTabChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <asp:UpdateProgress ID="UpdateProgressTabs" 
                    AssociatedUpdatePanelID="upTab_List" 
                    runat="server">
                    <ProgressTemplate>
                    Refreshing Tabs...<img alt="" src="Images/loader.gif" />
                    </ProgressTemplate>
                    </asp:UpdateProgress>
     4.  Register script in :  
    Protected Sub Page_Load ..........
    
           ScriptManager1.RegisterAsyncPostBackControl(Tabs)
    

     5. Finally add the method you want:

        Public Sub ActiveTabChangedServer(ByVal sender As Object, ByVal e As System.EventArgs)
            lblTotalCount.Text = "Captured!!!!"
        End Sub
     
    Wednesday, January 31, 2007 10:45 AM
  • User-563238995 posted

    Outstanding! How about the use of a master page?

    <script type="text/javascript">       
      function ActiveTabChanged(sender, e) {
      __doPostBack('TabsPublications', sender.get_activeTab().get_headerText());
      }
    </script>

     Then inside my content panel I have:

    <?xml:namespace prefix = asp /><asp:AsyncPostBackTrigger class=st ControlID=" 

    	ajaxToolkit:TabContainer runat="server" ID="TabsPublications"
    		OnClientActiveTabChanged="ActiveTabChanged" OnActiveTabChanged="ActiveTabChangedServer"
    ajaxToolkit:TabPanel runat="Server" ID="Panel1" HeaderText="All Publications"
    	ContentTemplate
    		asp:UpdatePanel ID="UpdatePanel1" runat="server"
    			ContentTemplate
    				asp:UpdatePanel ID="upTab_List" runat="server" UpdateMode="Conditional"
    					ContentTemplate
    					asp:GridView runat="server" ID="PubsGridView" AutoGenerateColumns="False" ShowHeader="False" CellSpacing="5" GridLines="None"
    					Columns
    						asp:TemplateField
    						   ItemTemplate
    								asp:HyperLink ID="HyperLink1" NavigateUrl='%# Bind("articleUrl") %' runat="server"asp:Label ID="Label1" runat="server" Text='%# Bind("articleName") %'/asp:Label/asp:HyperLink
    								asp:Label ID="Label2" runat="server" Text='%# Bind("Abstract") %'/asp:Label
    							/ItemTemplate
    						/asp:TemplateField
    					/Columns
    				/asp:GridView
    						asp:Label ID="lblTotalCount" runat="server" Text="Orig Load"/asp:Label
    					/ContentTemplate
    					Triggers
    						asp:AsyncPostBackTrigger ControlID="TabsPublications" EventName="ActiveTabChanged" /
    					/Triggers
    				/asp:UpdatePanel
    			/ContentTemplate
    		/asp:UpdatePanel
    	/ContentTemplate
    /ajaxToolkit:TabPanel
    
    ajaxToolkit:TabPanel runat="Server" ID="Panel3" HeaderText="Tab2" 
    	ContentTemplate
    		Do Something...
    	/ContentTemplate
    /ajaxToolkit:TabPanel
    /ajaxToolkit:TabContainer
     </asp:AsyncPostBackTrigger>Clicking a tab does a complete postback and does not save the tab state nor does it seem to execute ActiveTabChangedServer.
    Thursday, February 1, 2007 10:04 PM
  • User902366211 posted

    I think you need this instead, to get the right client-side control ID:

    __doPostBack('<%= TabsPublications.ClientID %>', sender.get_activeTab().get_headerText());

    Thursday, February 1, 2007 10:14 PM
  • User-563238995 posted
    Dead on, however I now notice that if I have a datagrid that performs a postback it now longer works. Ideas?
    Friday, February 2, 2007 4:07 PM
  • User-1071399013 posted

    yeap, worked for me with a CLIENT ID too. Excellent! Thanks for help.

    You may avoid postbacks by adding javascript and modifying your Hyperlink to simple link. (just an idea ...)

     /asp:GridView runat="server" ID="PubsGridView" AutoGenerateColumns="False" ShowHeader="False" CellSpacing="5" GridLines="None"
    Columns
    asp:TemplateField
    ItemTemplate
    asp:HyperLink ID="HyperLink1" NavigateUrl='%# Bind("articleUrl") %' runat="server"asp:Label ID="Label1" runat="server" Text='%# Bind("articleName") %'/asp:Label/asp:HyperLink
    asp:Label ID="Label2" runat="server" Text='%# Bind("Abstract") %'/asp:Label
    /ItemTemplate
    /asp:TemplateField
    /Columns
    /asp:GridView

     
    Friday, February 2, 2007 4:17 PM
  • User303152260 posted
    Anyone got this to work when the scriptmanager is on the master page?
    Monday, February 19, 2007 7:27 AM
  • User1075616431 posted

    Yeah, and how do you guys get javascript working?

    Monday, February 19, 2007 8:59 AM
  • User-1238090861 posted

    I have been trying to figure out how to do postback from Tab Container and this thead have helped me out to resolve this. Thanks guys!!!!!!!!!

    Friday, February 23, 2007 2:20 PM
  • User-1414234670 posted

    Hello, I want to do the same thing, be able to load data from server each time I click on a Tab.<o:p></o:p>

    I read this forum and try the code provided, and also the code from this page :  http://willys-web.blogspot.com/2007/02/aspnet-ajax-control-toolkit-tab-control.html<o:p></o:p>

    The code from willy-web does work when I run it separatly in a new web site, from Visual Studio 2005. Try it, it works. When I put a break point in the code inside the function ''DoServerSideValidation", I have a break when I click on the second tab.<o:p></o:p>

    Perfect, I said, just have to fit it in my code. But even by copying the code I can not run my freaking ''DoServerSideValidation" function !<o:p></o:p>

    I know it is possible, take a look here and here . But I'd like to do it myself....<o:p></o:p>

    Lets have a look to the javascript function :<o:p></o:p>

        function ActiveTabChanged(sender, e)
        {
              alert('Hi !');    
              __doPostBack('<%= tabs1.ClientID %>', sender.get_activeTab().get_headerText());
        }<o:p></o:p>

     This code is called, as I see a winpopup "Hi !" displayed when I click on one of my tabs...<o:p></o:p>

     Here is my TabContainer properties :<o:p></o:p>

     <cc1:TabContainer runat="server" ID="tabs1"
                OnClientActiveTabChanged="ActiveTabChanged"
                OnActiveTabChanged="DoServerSideValidation"><o:p></o:p>

    DoServerSideValidation is never triggered. If someone can help me to understand where is the link between " __doPostBack('<%= tabs1.ClientID %>', sender.get_activeTab().get_headerText()); "<o:p></o:p>

    and my function DoServerSideValidation....<o:p></o:p>

    And why the code from willy-web doesn't not work inside my web project. Is it because I use a control ascx ? so in the page load I do this ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(tabs1);<o:p></o:p>

    You know what is funny ? The code I search is used when you are editing a post, here in this forum. (Tabs "Compose", "Options", "Related", "Preview").<o:p></o:p>

    Ok, if someone have an idea of how this TabContainer works .... It would be appraciated...<o:p></o:p>

    Thanks for your help.
    <o:p></o:p>

    <o:p> </o:p>

    Wednesday, February 28, 2007 10:50 AM
  • User-1071399013 posted

    I would step through the events that happen on Page.IsPostback in Page_load method. If nothing is happening - your trigger is not seeing/registered correctly.

    Wednesday, February 28, 2007 11:10 AM
  • User-452893294 posted

    This is the solution I've been looking for, however, I get the following error when I try to run the code below. Does anyone else get the same error?

     "The name 'CurrentTab' does not exist in the current context"

     

    ************************************

     <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

    <title>Untitled Page</title>

    <script type="text/javascript">

     

    function ActiveTabChanged(sender, e) {

    var CurrentTab = $get('<%=CurrentTab.ClientID%>');

    CurrentTab.innerHTML = sender.get_activeTab().get_headerText();

    //add a custom postback

    __doPostBack('Tabs', sender.get_activeTab().get_headerText());

    Highlight(CurrentTab);

    }

     

    </script>

     

    </head>

    <body>

     

    <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

    </asp:ScriptManager>

     

    <div>

     

    <cc1:TabContainer ID="Tabs" runat="server" OnClientActiveTabChanged="ActiveTabChanged" OnActiveTabChanged="ActiveTabChangedServer">

    </cc1:TabContainer>

     

     

     

    <cc1:TabPanel ID="TabPanel1" runat="server">

    <HeaderTemplate>TabA</HeaderTemplate>

    <ContentTemplate>

     

    <asp:UpdatePanel

    ID="upTab_List"

    runat="server"

    UpdateMode="Conditional">

     

    <ContentTemplate>

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    </ContentTemplate>

    <Triggers>

    <asp:AsyncPostBackTrigger

    ControlID="Tabs"

    EventName="ActiveTabChanged" />

    </Triggers>

     

    </asp:UpdatePanel>

     

     

    <asp:UpdateProgress ID="UpdateProgressTabs"

    AssociatedUpdatePanelID="upTab_List"

    runat="server">

     

    <ProgressTemplate>

    Refreshing Tabs...

    </ProgressTemplate>

    </asp:UpdateProgress>

     

    </ContentTemplate>

    </cc1:TabPanel>

     

    </div>

    </form>

    </body>

    </html>

    Friday, March 2, 2007 5:21 PM
  • User-1312615075 posted

    Hi Steve,

    I am also doing the same thing but i am creating the controls dynamically.

    For me the javascript is called but the ActiveTabChanged event is not firing.

    It is in that event I am binding the grid with data, because this event is not getting fired my grid is not getting bindied with any data.

    Monday, March 5, 2007 4:19 AM
  • User1944889383 posted

    OK, i give up. i've been trying to get this working using all the suggestion in this thread. However it still doesnt work.

     Here is my scenario

     
    I have a Master Page, with a navigation pane on the left. Clicking a link here will cause a event to be raised on the content page. For this i have had to register the Master Page explicitly on the content page, there fore exposing the required event

    The code for this is here

    <%@ MasterType VirtualPath="~/private/PageStatusMaster.master" %>

    In my content page i have a tab container with the update panels and triggers decribed in previous posts.

     
    on the master page have my javascript function to do the post back

    and on the content page i handle the post back.

     
    Here is my code as it stands

    MASTER PAGE

      

    <head runat="server">
        <title id="pagetitle" runat="server"></title>
     <script type="text/javascript">       
      function ActiveTabChanged(sender, e) {
          alert('Hi !');    
      __doPostBack('TabsPublications.ClientID', sender.get_activeTab().get_headerText());
      }
    </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            
            <div id="leftcontent">
                <br />
                <h3>
                    Select a Project to Review</h3>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:ListBox ID="lb_projectlist" runat="server" AutoPostBack="True" Width="100%"
                            Height="100%"></asp:ListBox>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <div id="rightcontent">
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </div>
        </form>
    </body>

     Content Page

      

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ MasterType VirtualPath="~/private/PageStatusMaster.master" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="lbl_projectname" runat="server"></asp:Label>
                <cc1:TabContainer ID="TabsPublications" runat="server" OnClientActiveTabChanged="ActiveTabChanged"
                    OnActiveTabChanged="ActiveTabChangedServer">
                    <cc1:TabPanel ID="Panel1" runat="server" HeaderText="Structure View">
                        <ContentTemplate>
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                    some content here.....
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="TabsPublications" EventName="ActiveTabChanged" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" ID="Panel2" HeaderText="test">
                        <ContentTemplate>
                            <asp:UpdatePanel runat="server" ID="UpdatePanel3">
                                <ContentTemplate>
                                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="TabsPublications" EventName="ActiveTabChanged" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </ContentTemplate>
                    </cc1:TabPanel>
                </cc1:TabContainer>
              </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Content>

     The code behind for this content page is here

      

     Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            'register the post back for the script manager and tab control
            Dim aSM As New ScriptManager
            aSM = Master.FindControl("ScriptManager1")
            aSM.RegisterAsyncPostBackControl(TabsPublications)
        End Sub
    
        
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
        Protected Sub ActiveTabChangedServer(ByVal sender As Object, ByVal e As System.EventArgs)
    
        End Sub

     OK, so with all this in place, when i click on a tab in the content page. my javascript function to do the post is called (i placed an alert in here) the content page page load event in then hit

    the page does a full post back refreshes and the tab does not change, nor does the server side event get hit.

    Any ideas what i have done wrong?

     Regards

     

    Dave Naylor
     



     

    Monday, March 5, 2007 5:37 AM
  • User1885608918 posted
    For those of you who are not seeing the events fired for LinkButton events or who lose their ActiveTab when clicking a LinkButton in a TabPanel, there is a simple workaround at the moment. Instead of using LinkButton, use a PushButton or any non-javascript:__doPostBack('controlname','') generating link. The problem appears to be that the TabContainer just isn't capturing the javascript link correctly.
    Tuesday, March 13, 2007 3:53 PM
  • User1836952011 posted

    I just upgraded to the latest AjaxToolKit 10301 and now I'm getting errors of:

     The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    Tuesday, March 20, 2007 1:37 PM
  • User1836952011 posted
     I moved the js function out of the head tag and it works now....
     function ActiveTabChanged(sender, e) {
                var CurrentTab = $get('<%=CurrentTab.ClientID%>');
                CurrentTab.innerHTML = sender.get_activeTab().get_headerText();
                //add a custom postback
                 __doPostBack('Tabs', sender.get_activeTab().get_headerText());
                Highlight(CurrentTab);
            }
    
     
    Tuesday, March 20, 2007 1:53 PM
  • User1512840900 posted

    You must generate the javascript code on server-side and then register the script.

    Tuesday, March 20, 2007 1:56 PM
  • User978043691 posted

    Hey Guys,

    I've got a similar issue but with slightly different behaviour. Having implemented the suggested the javascript solution for creating a postback, I can now get a specific tab change to be hit server side. That's great, but it then pops up with this dreaded javascript error, Sys.ArgumentUndefinedException which subsequently affects the way the entire tab container gets rendered on subsequent tab clicks. I've stripped everything out of the tab in question and even removed code from the Page Load method to narrow it down and now I'm pretty much out of options. I've registered the javascript on server-side and it has made no difference :(

    I'm using a master page, but mostly for design with very little code behind. The page has just 6 tabs, admittedly some of these tabs have child update panels within but it's nothing too convoluted. I do have validation running in some of the tabs.

     Has anyone found the cause and/or solution to this issue?

     Many Thanks

     Ben

    Tuesday, March 27, 2007 4:45 AM
  • User-2056338294 posted
    Can I ask a really obvious question? Why the heck is this control built so that it DOESN'T post back to the server when this event happens?  I'm really confused about this - why should the developer have to go through all of these machinations to get it to post back?  Is there some technical reason I'm missing?
    Monday, April 23, 2007 3:01 PM
  • User-1978334014 posted
    
    

    A much simpler approach which I've had to use elsewhere (such as with ModalPopupExtender) is to have a "hidden button' that does the PostBack (click event), and some JavaScript to Find-It and Click-It.

    (1) Include the "OnClientActiveTabChanged" event for the TabContainer

               <ajaxToolkit:TabContainer runat="server" ID="mTabContainer" OnClientActiveTabChanged="ActiveTabChanged">

    (2) Include a hidden button that calls the server event code you want , using the OnClick event

               <asp:Button id="tabClickButton" Visible="false" runat="server" OnClick="mTabContainer_ActiveTabChanged" />

    (3) Include JavaScript to click the hidden button - actioned when the user changes tab

               function ActiveTabChanged(sender, e)

               {

                          var tabClickButton = document.getElementById('<%= tabClickButton.ClientID %>');

                          if (tabClickButton != null)

                          {

                                     tabClickButton.click();

                          }

               }

    ** That's all I did - and it does the PostBack as you'd expect - and runs the server-side event - and stays on the same tab being displayed - EASY !!

     

    Monday, May 7, 2007 8:56 PM
  • User-1978334014 posted

    Update to previous post :

    If you use a button and then set "Visible=false", it doesn't get rendered, and thus can't be "clicked" from JavaScript.

    Instead - use a DIV tag around the button (DON'T set the button to invisible) :

         <div style="visibility:hidden">

              <asp:Button id="tabClickButton" runat="server" OnClick="mTabContainer_ActiveTabChanged" />

         </div>

    Monday, May 7, 2007 9:33 PM
  • User209296940 posted
    I've followed the instructions for this exactly and it won't fire the

    mTabContainer_ActiveTabChanged event.

     What am I missing?  Where should the button go?  I've tried it outside the Tabcontainer and inside the tabpanel.  Should there be a button inside each tabpanel?  I've put a break point on the mTabContainer_ActiveTabChanged event and it never gets in there.

    Thanks,

    Thursday, May 17, 2007 3:57 PM
  • User716346991 posted

    When working with Master Pages, there is a ScriptManagerProxy control which allows nested components to add script and service references if the parent page already contains a ScriptManager control. 

    To get this working when your ScriptManager is defined on a master page: 

    Folow nzolotar's post above but add a ScriptManagerProxy to your child page or control as below:

    <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server" />

    Then REPLACE the following code in nzolotar's post:

     Protected Sub Page_Load ..........

           ScriptManager1.RegisterAsyncPostBackControl(Tabs)      

    WITH:

     Protected Sub Page_Load .......... 

           ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(Tabs);

     Hopefully a 'AutoPostBack' property will be included in the next ToolKit release....

    Kyle

     

    Friday, May 18, 2007 11:43 AM
  • User209296940 posted

    Sorry for not being clear.  I'm not using MasterPages.  I need to know where the button goes and what else it takes to fire the activetabchanged event in the code.

    Friday, May 18, 2007 5:07 PM
  • User427745133 posted

    Hi!

     I encountered a problem similar to this. I solved it by placing the tabcontainer in an updatepanel and setting the AutoPostback Property to "true".

     

    Hope this helps.

    Tuesday, October 2, 2007 5:02 AM
  • Friday, October 19, 2007 2:43 AM
  • User-501180780 posted

    I too was having this problem of not getting the ActiveTabChanged event. Per barrysuku's post above, I see that this has been fixed in build 1.0.10606.

    I downloaded the latest release (Version 1.0.11119.0) from Codeplex and then added AutoPostBack="true" to the TabContainer element and now my server-side handler is getting called.
     

    Friday, December 21, 2007 9:34 AM
  • User-615120616 posted

    Did you ever find a solution. I am in EXACTLY the same boat. I just simply can't find a wait to make the server side event fire.

    Client-side no prob. Server-side no go.

     

    :-(

     

     

    Sunday, February 24, 2008 9:47 PM
  • User1600651573 posted

    I found a way around using the client call. I put the tabcontainer in a normal asp panel. Then put an updatepanel around the asp panel. That took care of the errors when surrounding a tabcontainer with an updatepanel:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

    <asp:Panel ID="pnlEditItem" runat="server" Visible="false">
        <cc1:TabContainer ID="TabContainer1" runat="server" Width="100%" AutoPostBack="true" OnActiveTabChanged="TabContainer1_ActiveTabChanged1">
            <cc1:TabPanel ID="tpEdit" runat="server">
                <ContentTemplate>

    various tabs and controls of some sort...

                </ContentTemplate>
                <HeaderTemplate>
                    Text Edit
                </HeaderTemplate>
            </cc1:TabPanel>

     </ContentTemplate>
    </asp:UpdatePanel>

    I then have the tabcontainer autopostback, this kicks off the codebehind tabindexchanged event:

    protected void TabContainer1_ActiveTabChanged1(object sender, EventArgs e)
            {
                ((TabContainer)sender).ActiveTab.TabIndex = (short)((TabContainer)sender).ActiveTabIndex;
            }

    After that, the active tab remains the last one selected until another one is clicked or some other codebehind changes the activetabindex. 

     

    Hope that helps 

    Friday, March 14, 2008 6:18 PM
  • User-462402336 posted

    Hi!!

    Thanks a lot!! This is exact one I was looking for...

    Ur style of - "documenting" everything to make a life easy, its really good & helps for better understanding!!

    Pragati 

     

     

     

    Friday, May 23, 2008 5:02 AM
  • User631344194 posted

    What you need is to follow this excellent demonstration which worked excellently for me. You will need to take note of the comments about the post back problem which is fixed by the following tweak in the javascript


    change:
    __doPostBack('btnOrdersTrigger', '');

    to:
    __doPostBack('<%= btnOrdersTrigger.UniqueID %>','');

     

    http://www.mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html

     

    Tuesday, July 22, 2008 9:43 AM
  • User-955326108 posted

    Hello,

    You can always set autopostback="true" on your tabcontainer and then handle the tabChanged event in code-behind: 

        Protected Sub Tabs_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tabs.ActiveTabChanged
            If Tabs.ActiveTabIndex.ToString = "1" Then
                'now the user selected tab number 2
            End If
        End Sub

     Cheers!

    /Eskil

    Saturday, January 24, 2009 6:10 AM
  • User-1512582634 posted

    Hello

    I have a label called "lblMessage" in the Master Page. I also have a aspx page wherein I put a TabContainer. When I enter some information on the first tab and i clicked the SAVE button, a message in the "lblMessage" said that the information has been succesfully saved. The problem is when I clicked the second tab, the message in my "lblMessage" doesn't cleared up.  My problem is when I clicked the 2nd tab, I want the "lblMessage" to be cleared. How can I solve this problem? Cry

    Monday, February 1, 2010 10:35 PM
  • User1075616431 posted

    I think you probably need to configure ajax for lblMessage to be updated by the tab control...

    Wednesday, February 3, 2010 4:22 AM
  • User675196781 posted

    just use autopostback="true"

    and the ActiveTabChanged event will fire as expected

    otherwise, this becomes a freak'in mess between various AJAX enabled products

    one note, sometimes the ActiveTabChanged event will fire twice (and has the correct index value on the 2nd call)

    rob

    tutor@ebiz-developer.com

    Tuesday, June 29, 2010 2:59 PM
  • User1407485359 posted

     

    Set TabContrainer control's to    AutoPostBack="true"

    After that tab click will get roundtrip at server then u can get tab index value.

    like:        int CurrentTab=TabContainer1.ActiveTabIndex;

    Tuesday, July 27, 2010 6:09 AM
  • User277463474 posted

    Sweet and simple!! Excellent. 

    Tuesday, November 9, 2010 10:40 AM
  • User-1524976742 posted

    Don't forget to set the AutoPostBack property

    // In aspx

    <ajaxToolkit:TabContainer ID="tabContainer" runat="server" 
                              CssClass="TabStyle" 
                              OnActiveTabChanged="tabContainer_ActiveTabChanged"  AutoPostBack="true">
    </ajaxToolkit:TabContainer>

     

     //On server side

    protected void tabContainer_ActiveTabChanged(object sender, EventArgs e)
    		{
    			TabContainer container = sender as TabContainer;
    			if (container.ActiveTabIndex == 1)
    			{
    				//doStuff			
                           }
    		}


     

     

     

     

    Wednesday, November 24, 2010 7:16 AM