Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a form, say: main.aspx

I have a button on it, on click event of button, I am setting the value of a session variable (say:
C#
Session["var"]="Value";
)

Now on the click event, I want to open the form (details.aspx) in new window and get that Session variable value on this page.


Please help?
Posted

You should be able to access using HttpContext

C#
HttpContext.Current.Session["var"]


Depending on the type of data you are storing in the session variable, you need to type cast it.
 
Share this answer
 
Session["var"] you can get directly value of session
C#
var r=Session["var"];
 
Share this answer
 
v2
Comments
Vipin_Arora 12-Jul-12 12:32pm    
Its fine session I can handle ...but my question is..I want want to open the page in new window... on click event of asp button
Under Button Click event

You have Set Session Variable like
C#
protected void Button1_Click(object sender, EventArgs e)
  { 
Session["var"]="Value";
Response.Redirect("details.aspx");
}

In details.aspx
Under Pageload you can get the session like

C#
protected void Page_Load(object sender, EventArgs e)
   {
string str=session["var"].tostring()//here the key name should be same as prevoius session key name
   }

Hope it will help you
 
Share this answer
 
Comments
Vipin_Arora 12-Jul-12 12:28pm    
Response.Redirect will not open it in new window..I want to open the details page in new window

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900