Thursday, May 1, 2008

AjaxControlToolkit TabContainer not maintaining ActiveTabIndex between postbacks - Workaround

Problem
The AjaxControlToolkit TabContainer does not maintain the state of its ActiveTabIndex if the postback is caused by a GridView or DataList.

Workaround
Add the following javascript to your page:

<script type="text/javascript">
function OnTabContainer_ActiveTabChanged(sender, args)
{
sender.get_clientStateField().value = sender.saveClientState();
}
</script>

And add the following attribute to your TabContainer:


OnClientActiveTabChanged="OnTabContainer_ActiveTabChanged"

No comments: