Get C# session variable using javascript

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I am new to web development at all but maintaining a .NET
site that utilizes .apsx pages using vbscript,
javascript,and C#.

There is a function I am doing that I only can find out
how to do in javascript (direct url post to variable then
close window), however now I need to access a session
variable from that javascript. I could do it from a C#
page doing the following:

(string)HttpContext.Current.Session["myLearningUrl"];

Anyone know how I can do it in javascript?

thanks
 
The session variables belong to the web server, and are held in the session
collection on the server, your javascript runs within the client, as part of
the page request output. The easiest way to access it from javascript would
be to put it in a hidden field in your page output and access it as a simple
html field in your client side javascript.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
Back
Top