Hi all
How does one use the ViewState property? I need to persist a variable setting through a page repost and I have put the following code in the CLICK event of a button:
ViewState["ErrorState"] = "username";
When the page reloads, I use the following code:
if (Page.IsPostBack == true)
errorstate = (string)ViewState["ErrorState"].ToString();
and it gives me the following error:
Object reference not set to an instance of an object.
Now --- what am I doing wrong here??
Thanks as always
Craftor
How does one use the ViewState property? I need to persist a variable setting through a page repost and I have put the following code in the CLICK event of a button:
ViewState["ErrorState"] = "username";
When the page reloads, I use the following code:
if (Page.IsPostBack == true)
errorstate = (string)ViewState["ErrorState"].ToString();
and it gives me the following error:
Object reference not set to an instance of an object.
Now --- what am I doing wrong here??
Thanks as always
Craftor