Tuesday, June 2, 2009

Getting active tab index of a tab using Javascript

Javascript File

function SaveActiveTabIndex(sender)
{
var activetabindex = sender.get_activeTab().get_tabIndex();
setCookie(activetabindex);
}

function setCookie(value)
{
document.cookie = "tabIndex=" + escape(value);
}

C# File

Register the tab control with OnClientActiveTabChanged.e.g.

tabProgramInfo.OnClientActiveTabChanged = "SaveActiveTabIndex";

and retrive the active tab index of this tab control from cookie.

int activeTabIndex=Convert.ToInt32(Server.HtmlEncode(Request.Cookies["tabIndex"].Value));

No comments:

Post a Comment