How to find the selected Tab in a TabPanel

Rate It (1)

Last post 07-01-2007 5:03 PM by Rasetti. 3 replies.

Sort Posts:

  • How to find the selected Tab in a TabPanel

    06-30-2007, 9:27 PM
    • Member
      13 point Member
    • vkrs
    • Member since 11-11-2005, 11:46 AM
    • Posts 4

    Hi,

     I am a newbie to AJAX and .NET and cannot seem to solve the following.

     I have a Tabcontainer which has 5 tab panels.

    The Tabcontainer is contained within a table.

    I have another table which has a few buttons and I would want to do something onclick of one of the button's depending on whats within the tabpanel.  As per some of the forum posts I have a Label in the 2nd table which I use to store the current selected Tab.  The script is as below:

    function ActiveTabChanged(sender, e)
                    {
                        var CurrentTab = $get('<%=Label1.ClientID%>');
                        Label1.innerHTML = sender.get_activeTab().get_headerText();
                        __doPostBack('<%= TabContainerBatch.ClientID %>', sender.get_activeTab().get_headerText());
                       
                    }

     

    Depending on the value of Label1.Text I want to do something serverside.  After the page is rendered for some reason I cannot seem to read the value of Label1 although the display of Label1 changes to the correct TabPanel headerText onclick of any TabPanel. Label1.Text from within Page load always seems to return the default value whereas the display seems to show me the right value of the headertext of the selected TabPanel. Can you please let me know what I might be doing wrong here.

  • Re: How to find the selected Tab in a TabPanel

    06-30-2007, 11:39 PM
    Answer
    • Participant
      1,216 point Participant
    • Rasetti
    • Member since 04-17-2006, 6:40 PM
    • Auckland, New Zealand
    • Posts 286

    Hi!

    A better approach would be to set the AutoPostBack property in the TabContainer to "true" and then catch the TabContainer_ActiveTabChanged event, and there, server-side, do all the manipulations you need.

    Remember that you can use the TabContainer.ActiveTabIndex property to get the active panel index or the TabContainer.ActiveTab property to get the panel itself.

     

    Hope this helps,

    Juan Barrera
    MCTS


    Please remember to click "Mark as Answer" on this post if it helped you.
  • Re: How to find the selected Tab in a TabPanel

    07-01-2007, 1:42 PM
    Answer
    • Member
      13 point Member
    • vkrs
    • Member since 11-11-2005, 11:46 AM
    • Posts 4

     Hi Rasetti,

     Thanks for the reply.  I should have used TabContainer.ActiveTabIndex.  Don't really know why I wanted to do manipulations based on HeaderText value.

     Thanks,

    VS

     

  • Re: How to find the selected Tab in a TabPanel

    07-01-2007, 5:03 PM
    Answer
    • Participant
      1,216 point Participant
    • Rasetti
    • Member since 04-17-2006, 6:40 PM
    • Auckland, New Zealand
    • Posts 286

    Hey, I'm glad it worked!

    Could you please mark the right post as the answer, to close the thread? Thanks!

     

    Cheers,

     

    Juan Barrera
    MCTS


    Please remember to click "Mark as Answer" on this post if it helped you.
Page 1 of 1 (4 items)