Tôi có TabContainer với 3 TabPanel, giờ tôi muốn click 1 TabPanel nào đó, nó sẽ điều hướng sang sang khác. Ở đây Tôi sẽ hướng dẫn bạn sử dụng sự kiện ActiveTabChanged với thuộc tính AutoPostBack="true" đối với Tab Tôi cần điều hướng.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TabContainer ID="TabContainer1" runat="server" Width="600" ActiveTabIndex="0"
OnActiveTabChanged="TabContainer1_ActiveTabChanged" AutoPostBack="true" OnClientActiveTabChanged="changeTab">
<asp:TabPanel ID="TabPanel1" runat="server">
<HeaderTemplate>
Personal Details</HeaderTemplate>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="First Name"></asp:Label>
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox><br />
<asp:Label ID="Label2" runat="server" Text="Surname"></asp:Label>
<asp:TextBox ID="txtLName" runat="server"></asp:TextBox><br />
<asp:Button ID="btnPersonal" runat="server" Text="Save" OnClick="btnPersonal_Click" /><br />
<asp:Label ID="lblTabId1" runat="server"></asp:Label>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server">
<HeaderTemplate>
Educational Details
</HeaderTemplate>
<ContentTemplate>
<asp:Label ID="lblQualification" runat="server" Text="Qualification"></asp:Label>
<asp:TextBox ID="txtQualification" runat="server"></asp:TextBox><br />
<asp:Label ID="lblCollege" runat="server" Text="College"></asp:Label>
<asp:TextBox ID="txtCollege" runat="server"></asp:TextBox><br />
<asp:Button ID="btnQualification" runat="server" Text="Save" /><br />
<asp:Label ID="lblTabId2" runat="server"></asp:Label>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel3" runat="server">
<HeaderTemplate>
Professional Details
</HeaderTemplate>
<ContentTemplate>
<asp:Label ID="lblCompany" runat="server" Text="Comapny"></asp:Label>
<asp:TextBox ID="txtCompany" runat="server"></asp:TextBox><br />
<asp:Label ID="lblLocation" runat="server" Text="Location"></asp:Label>
<asp:TextBox ID="txtLocation" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnProfessional" runat="server" Text="Save" /><br />
<asp:Label ID="lblTabId3" runat="server"></asp:Label>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Sự kiện như sau:
protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
{
if (TabContainer1.ActiveTabIndex == 1)
Response.Redirect("http://dotnet.vn");
}