I want to share the currentTab
variable which exists on the C# server side with JavaScript. Here is my code:
C#:
public
You can write the index from your javascript function, to a hiddenfield, and then read that on postback.
In your code, you check the hiddenfield, if your page is postback. Like so:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
currentTab = Int32.Parse(HiddenTabValue.Value);
}
}
Have a server side hidden field to hold this piece of information.
You can access the field through javascript and as a server side control the value will be available server side.
You need to use some server control to send value back to the server (i.e. asp:HiddenField
) or use query string to set the tab index there.