2013-10-25 16 views
2

我正在使用ASP AjaxControlToolkit選項卡。我的問題是每當用戶更改選項卡時,url應根據各自的選項卡進行更改。重定向選項卡上的URL更改

這是我的代碼:

<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> 

對於實施例 - 如果用戶選擇:

  • Tab1 - 地址應該是/WebForm1.aspx
  • Tab2 - 地址應該是/WebForm2.aspx
  • Tab3 - 網址應該是/WebForm3.aspx

回答

0

試試這種方式,使用OnActiveTabChanged事件重定向頁面。

HTML代碼

<asp:TabContainer ID="TabContainer1" AutoPostBack="true" 
     OnActiveTabChanged="tbMain_ActiveTabChanged" runat="server" Width="100%" Height="100%"> 

服務器側

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); 
    } 
    }