0

This probably has been asked many times before but I was wondering how to maintain the ActiveTabIndex of an AjaxControlToolKit TabContainer.

The only way I can think of achieving such a thing is to store the ActiveTabIndex in the session and checking for this on postback. Are there any other solutions to solve this problem?

4

3 回答 3

1

玛拉基,没必要在这件事上惹上 Session。

只需将其放在“ActiveTabChanged”事件处理程序中(假设您使用的是 C#):

int iTabIndex = int.Parse(Request.Params["__EVENTARGUMENT"].Split(':')[1]);

然后根据“iTabIndex”的值执行您需要的任何逻辑。

于 2011-03-23T22:42:45.220 回答
1

很可能回答了你的问题。当这些东西还没有保存在那里时,它们属于页面的 ViewState。

编辑:另一方面:我已经对其进行了测试,并且我的 ActiveTabIndex 保持(异步)回发。

于 2010-09-23T12:52:31.987 回答
0

您需要为选项卡容器添加 ActiveTabChanged 事件,您可以将活动选项卡索引保持在视图状态,并在页面加载时检查它是否不为空,然后将其设置为活动选项卡索引。

 protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
    {
        ViewState["ActiveTabIndex"] = TabContainer1.ActiveTabIndex;

    }

PageOnLoad 事件代码

if (!(ViewState["ActiveTabIndex"] == null) )
        {            
               TabContainer1.ActiveTabIndex = (int)ViewState["ActiveTabIndex"];          

        }

确保在 TabContainer 标记中添加以下属性

AutoPostBack="true" OnActiveTabChanged="TabContainer1_ActiveTabChanged"
于 2013-10-10T11:53:04.903 回答