Mat*_*son 5 asp.net asp.net-ajax ajaxcontroltoolkit tabcontainer
我有一个ASP.NET页面,它使用ASP.NET Ajax Control Toolkit TabContainer.在这种情况Page_Load下,我隐藏了一些基于给予页面的数据的选项卡.然后,我想根据(可选)查询字符串参数的值使其中一个选项卡处于活动状态.
所以我有:
protected void Page_Load ( object sender, EventArgs e )
{
if ( !this.IsPostBack )
{
// Tabs with no data are hidden in here
LoadDataIntoTabs();
PreselectCorrectTab();
}
}
private void PreselectCorrectTab ()
{
if ( ctlTabContainer.Visible )
{
if ( !string.IsNullOrEmpty( Request.QueryString[ "tabIndex" ] ) )
{
int tabIndex = 0;
if ( int.TryParse( Request.QueryString[ "tabIndex" ], out tabIndex ) )
{
if ( ( ctlTabContainer.Tabs.Count > tabIndex ) && ctlTabContainer.Tabs[ tabIndex ].Visible )
{
ctlTabContainer.ActiveTabIndex = tabIndex;
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用tabIndex查询字符串参数集点击页面,则整个选项卡容器将消失.
奇怪的是,如果我LoadDataIntoTabs()改为不隐藏不包含数据的标签,一切都按预期工作(即在页面渲染时选择正确的标签).
有任何想法吗?
编辑
根据要求,这里有更多细节:
private void LoadDataIntoTabs ()
{
LoadPendingWidgetsTab();
LoadDataIntoTab2();
LoadDataIntoTab3();
// etc...
}
private void LoadPendingWidgetsTab ()
{
IList<Widget> pendingWidgets = GetAllPendingWidgets();
if ( ( pendingWidgets != null ) && ( pendingWidgets.Count > 0 ) )
{
tbpPendingWidgets.Visible = true;
tbpPendingWidgets.HeaderText = String.Format( "Pending Widgets ({0})", pendingWidgets.Count );
grdPendingWidgets.DataSource = pendingWidgets;
grdPendingWidgets.DataBind();
}
else
{
tbpPendingWidgets.Visible = false;
}
}
Run Code Online (Sandbox Code Playgroud)
尝试通过ActiveTab设置所需的选项卡,如:
ctlTabContainer.ActiveTab = tbpPendingWidgets;
如果将第一个选项卡设置为,Visible=false则必须通过ActiveTab设置下一个可见选项卡页面.
我正在使用AjaxControlToolkit Release 30930(2009年9月).
| 归档时间: |
|
| 查看次数: |
47244 次 |
| 最近记录: |