开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜