Solved

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

Posted on 2008-10-15
3
541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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