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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Oct 26, 2010, 10:59 PM EDT
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.
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Oct 28, 2010, 4:29 AM EDT