Save int on page with Viewstate
-
Hi, i would saving a int in variable, When there is the post of variable, I want this record remains variable in the page despite updating the page, I do as follows:
public string s;
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Form["champ"] != "")
{ s = Request.Form["champ"]; }ViewState\["s"\] = s; string s1 = ViewState\["s"\].ToString();
}
an error was shows : The reference object is not defined by an instance of an object , on line : string s1 = ViewState["s"].ToString(); Please help me to resolve this great problem, thank you very mutch.
-
Hi, i would saving a int in variable, When there is the post of variable, I want this record remains variable in the page despite updating the page, I do as follows:
public string s;
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Form["champ"] != "")
{ s = Request.Form["champ"]; }ViewState\["s"\] = s; string s1 = ViewState\["s"\].ToString();
}
an error was shows : The reference object is not defined by an instance of an object , on line : string s1 = ViewState["s"].ToString(); Please help me to resolve this great problem, thank you very mutch.
-
Hi, i would saving a int in variable, When there is the post of variable, I want this record remains variable in the page despite updating the page, I do as follows:
public string s;
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Form["champ"] != "")
{ s = Request.Form["champ"]; }ViewState\["s"\] = s; string s1 = ViewState\["s"\].ToString();
}
an error was shows : The reference object is not defined by an instance of an object , on line : string s1 = ViewState["s"].ToString(); Please help me to resolve this great problem, thank you very mutch.