简体   繁体   中英

Set Active Tab for AJAX Tab Control

I have a website that uses the AJAX TabContainer and has several tab panels. Each tab panel consists of a customer user control with many controls on it. I need to be able to set the active tab whenever server-side button click event is executed. How would I go about accessing the TabContainer from the custom controls C# code behind?

My markup is structured like this:

<cc1:TabContainer ID="TabRoot" runat="server" Width="100%" CssClass="ajax__tab_yuitabview-theme" onActiveTabChanged="TabRoot_ActiveTabChanged" 
    OnClientActiveTabChanged="SetIndex" ActiveTabIndex="0" AutoPostBack="True">
      <cc1:TabPanel ID="TabPatientRoot" runat="server" HeaderText="Patient">
        <ContentTemplate>
              <custom:Patient ID="PatientInfo" runat="server" Visible="False"></custom:Patient>
        </ContentTemplate>
      </cc1:TabPanel>
</cc1:TabContainer>

It is necessary that the server side codes executes a SaveData function before the tab panel is changed because whenever the active tab changes it loads the information for the newly selected tab panel, thus losing any information that wasn't saved on the previous tab panel.

How can I accomplish executing the server side SaveData function, and then have access to TabRoot to change the active tab? Currently I was using a javascript function (in the OnClientClick for the save button) to set the active tab but it is being executed before the server-side SaveData function. This seems to be a problem for users in IE9, only.

尝试这样,并参考此示例Ajax Control工具箱

TabRoot.ActiveTabIndex = 0;  // set your active tab index to display. 

尝试在按钮回发事件中设置选项卡的ActiveIndex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM