Home » ASP.NET » Tab Control ActiveTabIndex Lost on Postback

Tab Control ActiveTabIndex Lost on Postback

tran-land-01 I just got off the phone with a client who is using the MS-AJAX TabControl in one of his applications and any time he causes a postback, the tab resets to the first tab.

If you’ve never seen the problem, you’re lucky.  There are a couple of ways around the problem.  The first and easiest if it works in your situation is to put the tab in an update panel so that you never actually do a full postback.

However, there are times when this won’t work.  In this particular case it is because one of the tabs holds the file upload control, which can’t be used inside an update panel.  (Another problem we had to find a way around last week.)

What do you do then?

Turns out this is a bug in the way that the tab works.  This problem turns up in various situations.  If you are fighting the bug, the solution is actually pretty simple.

First, put the following  javascript in your aspx or ascx file:

    <script type="text/javascript">
        function TabChanged(sender, args)
            sender.get_clientStateField().value =

And then wire up the TabChanged function to your tab control:

<ajaxControlToolkit:TabContainer ID="TabContainer1" 
    runat="server" OnClientActiveTabChanged="TabChanged" >
</ajaxControlToolkit:TabContainer> />


This will fix the problem.


Other post in ASP.NET

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS. Does your team need additional help in any of the above? Contact Dave today.

Leave a Reply

3 Comments on "Tab Control ActiveTabIndex Lost on Postback"

newest oldest most voted
Notify of
Ananda Vardhan

Thank you very much for the post. It exactly solved my problem 🙂

Anna Gonzales

Do I need to remove the UpdatePanel just to make this work?

Dave Bush

No. I’m having trouble understanding why you would think that