TabContainer LoadClientState Failed

We have a set of small Javascript functions that retain the ActiveIndex of an ASP Ajax Toolkit TabContainer control and restores it on postback. Sometimes, perhaps due to increased sunspot activity, our TabContainer ClientState disappears. Resulting in the intruiging and quite humorous error “When casting from a number, the value must be a number less than infinity.”

To this day I have no idea what causes TabContainer to lose its state, but courtesy of a fellow traveller in pain, I can present a workaround.

Meet The Javascripts

Here’s our happy little Javascript family from the picturesque village of MarkUp

In Head

function saveCurrentTabIndex()
var tabcontainer = $get('').control;
var tabIndex = $get('');
if (tabcontainer != null)
tabIndex.value = tabcontainer.get_activeTabIndex();

function restoreCurrentTabIndex()
var tabIndex = $get('tabIndexHidden');
if (tabIndex.value > -1)
var tabcontainer = $find( '');
var index = tabcontainer.get_activeTabIndex();
if (index != tabIndex.value)

In Body
input type=”hidden” id=”tabIndexHidden” runat=”server”

Last thing in markup:

function pageLoad(sender,e)

Family Dysfunction

So, like I said, sometimes TabContainer ClientState is null causing the bizarre ‘number must be less than infinity’ error message, I assume because null is not less than infinity. To work around it use the Javascript parseInt function to make sure TabContainer has an ActiveTabIndex it can grok.

Resolving Our Little Differences

In saveCurrentTabIndex:

Now the ActiveTabIndex will be less than Infinity to the relief of all concerned with the possible exception of Buzz Lightyear.

Our Family Counsellor can be located here.. Thanks djs25uk 🙂


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: