Solved

How can I get and set a session variable from client script?

Posted on 2008-10-15
3
484 Views
Last Modified: 2012-05-05
Hi,

I have a problem where I need to read the current value of a session variable, do some calculations in the client side javascript and then set the same session variable to a new value.  Some quick searches indicate that it can be done using some AJAX.NET library but I am already using the ASP.NET 3.5 SP1 framework and AJAX Toolkit.  Is there some way I can do this without adding the AJAX.NET library?

Thanks!
0
Comment
Question by:TerryDean
3 Comments
 
LVL 8

Assisted Solution

by:rlh68
rlh68 earned 50 total points
ID: 22724610
Store you session variable in a cookie (if possible) then just read and update the cookie from client side javascript without the AJAX call.
0
 
LVL 2

Accepted Solution

by:
JasonChandler earned 400 total points
ID: 22724624
You can not set a session via Javascript. Please see this link, you will have to use page methods I think which will be possible since you are using 3.5
http://weblogs.asp.net/sohailsayed/archive/2008/02/23/calling-methods-in-a-codebehind-function-pagemethods-from-client-side-using-ajax-net.aspx
0
 
LVL 13

Assisted Solution

by:sm394
sm394 earned 50 total points
ID: 22724728
Assign Session value to Hidden Fileld which you can access on client side with Javascript like this
var session=document.getElementById('<%=hdnTest.ClientID%>')
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now