What am I doing wrong here. I can't get ViewState to work:
protected void Page_Init(object sender, EventArgs e)
{
Method1();
}
private void Method1()
{
Element.Click += new EventHandler(Button_Click);
}
public void Button_Click(object sender, EventArgs e)
{
if(ViewState["x"] != null)
// use ViewState["x"] from previous Page Init
//do processing ...
//in the end, store value for future use
ViewState["x"] = myLabel.Text;
}
I am reloading the page, so first the Page Init is triggered, where I do changes, before these changes I read from ViewState previous value of a variable, then I do processing, then override that value for subsequent use (in my next Page Init), after which I override it again.
Problem is my ViewState is null , it doesn't store/remember the value I gave it at the previous page init Thank you