[英]Redirect url on tab change
I am using ASP AjaxControlToolkit tabs. 我正在使用ASP AjaxControlToolkit选项卡。 My problem is whenever user change tab, url should change according to the respective tab.
我的问题是,每当用户更改选项卡时,URL都应根据相应的选项卡进行更改。
Here is my code: 这是我的代码:
<asp:TabContainer ID="TabContainer1" runat="server" Width="100%" Height="100%">
<asp:TabPanel ID="TabPanel1" runat="server">
<HeaderTemplate>Tab1</HeaderTemplate>
<ContentTemplate></ContentTemplate>
<asp:TabPanel ID="TabPanel1" runat="server">
<HeaderTemplate>Tab2</HeaderTemplate>
<ContentTemplate></ContentTemplate>
<asp:TabPanel ID="TabPanel1" runat="server">
<HeaderTemplate>Tab3</HeaderTemplate>
<ContentTemplate></ContentTemplate>
For Example - If user selects: 例如-如果用户选择:
Tab1
- Url should be /WebForm1.aspx Tab1
网址应为/WebForm1.aspx Tab2
- Url should be /WebForm2.aspx Tab2
- URL应该是/WebForm2.aspx Tab3
- Url should be /WebForm3.aspx Tab3
网址应为/WebForm3.aspx Try this way , redirect the page by using OnActiveTabChanged
event . 尝试这种方式,通过使用
OnActiveTabChanged
事件重定向页面。
Html code HTML代码
<asp:TabContainer ID="TabContainer1" AutoPostBack="true"
OnActiveTabChanged="tbMain_ActiveTabChanged" runat="server" Width="100%" Height="100%">
server side 服务器端
protected void tbMain_ActiveTabChanged(object sender, EventArgs e)
{
try
{
if (TabContainer1.ActiveTabIndex == 1)
{
Response.Redirect("~/WebForm1.aspx")
}
if (TabContainer1.ActiveTabIndex == 2)
{
Response.Redirect("~/WebForm2.aspx")
}
}
catch (Exception ex)
{
Support.ExceptionHandler.HandleException(ex);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.