Solved

Ajax Tab Control Disappears when using the OnClientActiveTabChanged Property

Posted on 2010-08-31
2
1,025 Views
Last Modified: 2012-05-10
Scenario:
I am using the AJAX TabControl and have some javascript to control the ActiveTabIndex on postback as I have some Dropdowns in each tab that cause it to revert back to index 0.   So I added some javascript to control this and call it by setting the OnClientActiveTabChanged Property on the Tab Control.  As soon as I do that and run the debugger to test the Entire Tab Control disappears.  For some reason by setting this property cause the control not to be rendered in the browser.   Need some help in finding out why so I can test to see if this javascript will work.  

Here is My Code:

Tab Control:
<cc1:TabContainer ID="TabContainerAdmin" runat="server" OnClientActiveTabChanged="SaveActiveTabIndex" ActiveTabIndex="0" Enabled="true">
        <cc1:TabPanel ID="TabPanelCircuit" runat="server" HeaderText="Manage Circuit Data">

JavaScript

<script type="text/javascript">
function SaveActiveTabIndex(sender, e)
{
var activetabindex = sender.get_activeTab().get_tabIndex();
setCookie(activetabindex);
}
function setCookie(value)
{
document.cookie = “tabIndex=” + escape(value) ;
}

</script>

Code Behind Function called on PageLoad Event

protected void ChangeTabIndex()
    {
        if (Request.Cookies["tabIndex"] != null)
        {
            int index = int.Parse(Server.HtmlEncode(Request.Cookies["tabIndex"].Value));

            if (index > -1 && index < TabContainerAdmin.Tabs.Count)

            {
                TabContainerAdmin.ActiveTabIndex = index;
            }

            else
            {
                TabContainerAdmin.ActiveTabIndex = 0;
            }
        }
    }

0
Comment
Question by:jholmes0724
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
ID: 33623856
TabContainerAdmin.ActiveTabIndex has both get and set

so , I think, there is no need for you to store the tab index in the cookie, you can get the active tabindex in the page load by

TabContainerAdmin.ActiveTabIndex
0
 

Author Closing Comment

by:jholmes0724
ID: 33626505
Yes I did come to that conclusion as well.  Thanks for responding.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question