Solved

Ajax Tab Control Disappears when using the OnClientActiveTabChanged Property

Posted on 2010-08-31
2
1,026 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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