?
Solved

Ajax Tab Control Disappears when using the OnClientActiveTabChanged Property

Posted on 2010-08-31
2
Medium Priority
?
1,027 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

777 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