How to move to a particular tab present in a aspx page using asp.net
am using vantage.aspx page i开发者_如何学Gon my asp.net application, which contains tabpanels like "tabpnlvantage", "tabpnlCell","tabpnlGrid". I have a link button in my "Home.aspx" page, if i select a particular link button in "home.aspx" page it should navigate to the "tabpnlvantage" tab in the "vantage.aspx page". how should i do this, can any one help me out. thanks in advance.
Use QueryString. In Home.aspx:
<a href='vantage.aspx?tab=tabpnlvantage' />
In vantage.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if(! IsPostBack) {
var tab = Request.QueryString["tab"];
if(! string.IsNullOrEmpty(tab)) {
foreach(TabPanel t in TabContainer.Tab) {
if(t.ID == tab)
{
TabContainer.ActiveTab = t;
break;
}
}
}
}
}
Not quite sure it works like that. When you click on the required 'tab', the associated content should be displayed.
Use TabContainer1.ActiveTabIndex = 2;
tab index starts from 0.
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<ajaxToolkit:TabPanel ID="tabpnlvantage" HeaderText="Header1" runat="server">
<ContentTemplate>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="tabpnlcells" HeaderText="Header2" runat="server" >
<ContentTemplate>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="tabpnlgrid" HeaderText="Header3" runat="server">
<ContentTemplate>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
精彩评论