I want to get and set the value on session variable using javascript
i am using this
var a = '<%=Session("name")%>';
But this will give error for the <> this tag.This tag will be Expected.
Thanks & Regards,
Brijesh Mandaliya
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jiteendra SampathiraoPosted Oct 28, 2010, 8:29 AM
Jiteendra SampathiraoPosted Oct 27, 2010, 2:59 AM
We can't assign value to session variable through JavaScript. Session variables are managed on the server; they are carried with the user across all pages.
Do it on server side..
Or, But there is a work around using AJAX...
var url = "yourpage.aspx?id= " + pageid;
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("POST", url, true);
req.send();
private void Page_Load(object sender, System.EventArgs e)
{
if(Request.QueryString["id"] != null)
{
Session["PAGEID"] =Request.QueryString["id"].ToString();
}
}
Here are the links, which might useful to you.
http://forums.asp.net/t/394291.aspx
http://forums.asp.net/t/1312549.aspx
http://forums.asp.net/t/1064192.aspx
http://p2p.wrox.com/javascript-how/11256-sharing-server-side-variable-client-side.html
Please accept the post as answer, if your query is resolved. Thank You.