You can use
<%=variable%> to get value from aspx.cs. Variable must be public in
aspx.cs file.
For example, you can use:
var date=”<%=DateTime.Now%>”; to get the server time.
Another example:
In your aspx.cs you can code like:
public partial class _Default : System.Web.UI.Page
{
public string CsVariable = "hello world";
}
And now you can bind any js vairable Like-
var javacriptVariable = "<%=CsVariable%>";
Also see..
Accessing C# Variables in JavaScript[
^]
Pass C# Values To Javascript[
^]