How do you access an asp.net code behind session object member variable in javascript?
<p>I have a class that handles all of my session variables in my asp.net application. Moreover, I sometimes store objects in the session variables so as to allow me to code very similar to a normal .net application.</p>

<p>For example, here is an object in a session variable:</p>

<pre><code>public cUser User
{
    get { return (cUser)HttpContext.Current.Session["CurrentUser"]; }
    set { HttpContext.Current.Session["CurrentUser"] = value; }
}
</code></pre>

<p>And here is the instance of MySessionClass:</p>

<pre><code>    public static MySessinClass Current
    {
        get
        {
            MySessionClass session = (MySessionClass)HttpContext.Current.Session["MySessionClass"];
            if (session == null) {
                session = new MySessionClass();
                HttpContext.Current.Session["MySessionClass"] = session;
            }
            return session;
        }
    }
</code></pre>

<p>So, in my code behind aspx page, I would just do something such as </p>

<pre><code>int userID = MySessionClass.Current.User.UserID;
</code></pre>

<p>This works great and I love it. However, I want to apply the same principle in javascript from my aspx page:</p>

<pre><code>var userID = &lt;%=MySessionClass.Current.User.UserID%&gt;;
</code></pre>

<p>However, when I access that webpage, I get an error saying that it does not recognize the MySessionClass object.</p>

<p>So, given the context that I am in, what would be the best way to reference that UserID variable, from the object, from the session, in javascript? Maybe my syntax to reference it is off or I am going at it the wrong way. Any help would be appreciated, thank you.</p>
