protected void Page_Load(object sender, EventArgs
e)
{
Int16 userId = 1;
Page.ClientScript.RegisterStartupScript(this.GetType(), "UserId",
"<script> var UserId=" + userId + "</script>");
}
In the above code, variable UserId is initialized by value 1 and we can access this value in client side.
<script type="text/javascript" language="javascript">
$(document).ready(function () {
GetServerSideValue();
});
function GetServerSideValue() {
alert(UserId);
}
</script>