Well there is one shortcut we used to use during the ASP days, this still works in ASP.NET
In the page codebehind declare a public property say public int MyInteger
In the aspx put this
<script>
function GetMyValue()
{
var someVar = <%=this.MyInteger%>;
//Do something
}
</script>
To do it nicely, you can use
RegisterClientScriptBlock [
^]
string script = string.Format("var myVariable = '{0}';", vaiable.ToString());
if (!ClientScript.IsClientScriptBlockRegistered("myScript"))
{
ClientScript.RegisterClientScriptBlock(typeof(_Default), "myScript", script, true);
}