Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here a new solution that does almost what your need :</p> <ol> <li>The <code>OnClientActiveTabChanged</code> event is raised</li> <li>The <code>tabcontainer</code> New Tab index is saved in a <code>Hiddenfield</code></li> <li>The <code>tabindex</code> is reset to it's old value (so it wont change right now)</li> <li>The form trigger a asyncpostback using a hidden button.</li> <li>Within the hidden button's <code>Click event</code>, the OldTabIndex and NewTabIndex are retrieved.</li> <li>At the end of the Click event, the tabcontainer's <code>tabindex</code> is switched to the new value.</li> </ol> <p>So, the hidden button's Click event is executed before the TabContainer tab is changed.</p> <p>aspx:</p> <pre><code>&lt;asp:Button runat="server" ID="hiddenTargetControlForTabContainer" style="display:none" /&gt; &lt;asp:UpdatePanel ID="TabContainerUpdatePanel" runat="server"&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="hiddenTargetControlForTabContainer" /&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;asp:HiddenField ID="TabContainerActiveTab" runat="server" Value="0" /&gt; &lt;AjaxControlToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" OnClientActiveTabChanged="OrderTabContainerClientActiveTabChanged" &gt; &lt;AjaxControlToolkit:TabPanel runat="server" ID="TabPanel1" HeaderText="TabPanel1" &gt; &lt;ContentTemplate&gt; &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;/ContentTemplate&gt; &lt;/AjaxControlToolkit:TabPanel&gt; &lt;AjaxControlToolkit:TabPanel runat="server" ID="TabPanel2" HeaderText="TabPanel2" &gt; &lt;ContentTemplate&gt; &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;/ContentTemplate&gt; &lt;/AjaxControlToolkit:TabPanel&gt; &lt;/AjaxControlToolkit:TabContainer&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;script type="text/javascript"&gt; var TabContainerActiveTabControlID = '&lt;%= TabContainerActiveTab.ClientID %&gt;'; var hiddenTargetControlForTabContainerControlID = '&lt;%= hiddenTargetControlForTabContainer.uniqueID %&gt;'; function OrderTabContainerClientActiveTabChanged(sender, args) { var TabContainerActiveTabControl = $get(TabContainerActiveTabControlID); var OldtabIndex = parseInt(TabContainerActiveTabControl.value); var NewtabIndex = sender.get_activeTabIndex(); if (!(OldtabIndex == NewtabIndex)) { sender.set_activeTabIndex(OldtabIndex); TabContainerActiveTabControl.value = NewtabIndex; __doPostBack(hiddenTargetControlForTabContainerControlID, ''); } } </code></pre> <p> </p> <p>Code behind:</p> <pre><code>Protected Sub hiddenTargetControlForTabContainer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles hiddenTargetControlForTabContainer.Click Dim oldActiveTabIndex = TabContainer1.ActiveTabIndex Dim newActiveTabIndex As Integer = Convert.ToInt32(TabContainerActiveTab.Value) 'your stuff here TabContainer1.ActiveTabIndex = newActiveTabIndex End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload