Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

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

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
TerryDean
Asked:
TerryDean
3 Solutions
 
rlh68Commented:
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
 
JasonChandlerCommented:
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
 
sm394Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now