Solved

Ajax Tab Control Disappears when using the OnClientActiveTabChanged Property

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now