Global variables and ViewState
-
Hi Gurus! I writting some kind of Web Application and here I got a few WebForms and I need to exchange some variables between these pages. Usually when on page1 user pick up some value in Grid I wrote following code Response.Redirect("../page1.aspx?MyVar="+textBox1.Text); actually I just making a page redirect on itself and then in page class I defined private static string MyVar=""; and OnLoad I wrote if(!this.IsPostBack) { if(Request["MyVar"]!="") { MyVar = Request["MyVar"]; DoSomeWork(MyVar); } } So i want ot ask you is this optimal solution to store page variables? I mean maybe exists some better solution then redirect page on itself? Maybe I should use ViewState to store page variables or somth.? xedom developers team
-
Hi Gurus! I writting some kind of Web Application and here I got a few WebForms and I need to exchange some variables between these pages. Usually when on page1 user pick up some value in Grid I wrote following code Response.Redirect("../page1.aspx?MyVar="+textBox1.Text); actually I just making a page redirect on itself and then in page class I defined private static string MyVar=""; and OnLoad I wrote if(!this.IsPostBack) { if(Request["MyVar"]!="") { MyVar = Request["MyVar"]; DoSomeWork(MyVar); } } So i want ot ask you is this optimal solution to store page variables? I mean maybe exists some better solution then redirect page on itself? Maybe I should use ViewState to store page variables or somth.? xedom developers team
Refer the good article about state management. http://www.informit.com/articles/article.asp?p=31842[^]