admin管理员组文章数量:1323378
I want to set session variable using javascript/jquery in my apsx page. Afterwards,I want to use that session variable in other page using jquery. Can anyone help me for this?
Thanks,
Priya
I want to set session variable using javascript/jquery in my apsx page. Afterwards,I want to use that session variable in other page using jquery. Can anyone help me for this?
Thanks,
Priya
- See this:- stackoverflow./questions/2114581/… – palaѕн Commented Apr 9, 2013 at 14:17
4 Answers
Reset to default 1You cannot set directly with javascript you need server side code for it. you can make an ajax call and pass parameter and set session there.
You can set the session variable value in hidden field when page is initially loaded like this:
<asp:HiddenField ID="HDSessionValue" runat="server" Value'<%#Session["CustomerID"]'/>
Now you can easily get the value from jquery or javascript like this:
$(document).ready(function(){
var SessionValue=$('#HDSessionValue').val();
alert(SessionValue);
});
You have two cases here ,
1) If you want to set the value of Session in client side on the page load it self you can use the hidden field to pass on the client side .
2) If you want to set the value on the client side without going to back to post back , you can opt for the AJAX method
you can assign the value of session
variable to JS
variable but to assign a value to session
variable you need something like ajax
working on server side
本文标签: getset session value in jqueryjavascriptStack Overflow
版权声明:本文标题:Get,set session value in jqueryjavascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742123130a2421815.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论