The SubmitBT_Click
-click event happens in a postback. But all variables (and controls) are disposed at the end of the page's lifecycle. So you need a way to persist your List
, e.g. in the ViewState
or Session
.
public List<String> Input
{
get
{
if (Session["Input"] == null)
{
Session["Input"] = new List<String>();
}
return (List<String>)Session["Input"];
}
set { Session["Input"] = value; }
}
Nine Options for Managing Persistent User State in Your ASP.NET Application