I want to share the currentTab variable which exists on the C# server side with JavaScript. Here is my code:
C#:
public int currentTab = 1;
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScript", "showTab(" + currentTab + ");", true);
}
JavaScript:
var currentTab = "<%=currentTab%>";
function showTab(index)
{
currentTab = index;
// Show tab at (index)
}
I used this approach to get the current tab again on PostBack. However, currentTab on C# is remains 1 after PostBack. How can I solve this issue?