I am really confused with this behavior. Can someone explain this to me?
I have the following class structure:
public abstract BaseUserControl : System.Web.UI.UserControl
{
public List<string> listFieldMapper = new List<string>();
}
public partial class Property : BaseUserControl
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
base.listFieldMapper.Add("test");
}
}
In a event handler of a button, (causes Postback), I can access the base.listFieldMapper
My understanding was that between postbacks, the state is not maintained, to be able to maintain the state, use the ViewState object. How is it that the list maintains the values?
On a side note, If I set the value of base.listFieldMapper
after OnInit
(Ex: Load), I have a null object after postback.