Store value in session
i want store a data in session at the time of button click and use these value at pageload
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 attend5days leftRegister
Joginder BangerRank #360 · 7K reputationPosted Nov 9, 2014, 7:08 PM EST
private void Page_PreInit(object sender, System.EventArgs e)
{ if ((Session == null)) { // Do something here } }
Riddhi ValechaRank #794 · 2.9K reputationPosted Nov 9, 2014, 7:08 PM EST
This is possible if there are 2 webpages.
Eg-
Webpage - 1
Button1_Click
{
Session["Value"] = "abcd";
Response.Redirect("~/WebPage-2",false);
}
-----
Webpage - 2
Page_Load
{
Label1.text = Session["Value"].ToString();
}
-----------------
Are there 2 web pages or just 1 ??
muthukumar146 reputationPosted Nov 9, 2014, 7:17 PM EST
when user click a button a value is assigned to session
2.when refresh a page it retrieve the value from session
muthukumar146 reputationPosted Nov 9, 2014, 7:18 PM EST
when user click a button a value is assigned to session
2.when refresh a page it retrieve the value from session
Joginder BangerRank #360 · 7K reputationPosted Nov 9, 2014, 7:32 PM EST
but you can try
$.session.set("userName", $("#uname").val());
for more information check this link
http://stackoverflow.com/questions/15510590/how-to-get-value-in-the-session-in-jquery
Joginder BangerRank #360 · 7K reputationPosted Nov 9, 2014, 7:35 PM EST
https://github.com/AlexChittock/JQuery-Session-Plugin/blob/master/jquery.session.js
save this jquery in your local drive and after then reference it on you respective page.