Asp.Net Change a value from another page
Hi I have 2 webpage in my asp.net project. I 开发者_JAVA技巧defined a int value in second page. i want to change int value from first page. How can I make this?
You can't change the variable directly. But you can use Session to achieve this.
In Page 1
Session["session-name"] = "5";
In Page 2
if (Session["session-name"] != null) // check the session if it is exist
{
int a;
try
{
a = int.Parse(Session["session-name"].ToString());
}
catch
{
a = 0; // you can set null too. Whatever you want
}
}
You likely want to use Session Variables. You can start learning here.
精彩评论