Is it possible to access public variables declared in the code behind from a JavaScript function, e.g.
var user = <%=User%>;
Where User is declared in the code behind as:
public string User = "";
And then set in the page_load event.
Is it possible to access public variables declared in the code behind from a JavaScript function, e.g.
var user = <%=User%>;
Where User is declared in the code behind as:
public string User = "";
And then set in the page_load event.
<script type="text/javascript">
var userID = '<%= UserID %>';
var courseID = '<%= CourseID %>';
.... more stuff....
</script>
Then set the values on Page_Load (or in the Page_Load for the master page).
public void Page_Load( object source, EventArgs e )
{
UserID = Session["userID"];
CourseID = Session["courseID"];
...
}
hope this will help you