?
Solved

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

Posted on 2008-10-15
3
Medium Priority
?
546 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 200 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 1600 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 200 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 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