Here are the steps that you will have to take:
in your code behind page"
private int _userId;
private int _courseId;
protected int CourseId
{
get { return _courseId;}
set { _courseId = value;}
}
protected int UserId
{
get { return _userId;}
set { _userId = value;}
}
Step 2 : based on your requirement now you have to set up those properties. The catch is that these properties should be set before they are referenced from the JavaScript. May be something like this in the Page_Load event
_userId = Session["userId"];
_courseId = Request.QueryString["CourseId"] != null ? Request.QueryString["CourseId"] : String.empty; of course you can parse them to appropriat type based on your requirements.
Finally, you can reference them in javascript as follows:
var currentUserId = '<% = UserId %>';
var currentCouseId = '<% = CourseId %>';
This should definitely work. I have used this approach in so many features in my Web App I am currently working.