Hi,
You can pass any variable from codebehind to client-side using properties. Define a Public
propery in codebehind:
C#
public int PropertyName {
get { return ViewState("PropertyName"); }
set { ViewState("PropertyName") = value; }
}
assign a value to the property and then get the value in javascript using this:
javascript
<% = PropertyName %>
Or
Put the ViewState's value in a hidden field and read the hidden field value in client-side
ViewState["Name"] = "This is ViewState value";
Page.ClientScript.RegisterHiddenField("hf1", ViewState["Name"]);
Javascript:
var strValue = document.getElementById("hf1");
I hope this will help you out.