I am generating dynamic html controls. The controls are being generated on Init, after the user has caused a postback by pressing a button. However, he needs to press it twice so that the controls are generated. How can I fix this? Code:
protected override void OnInit(EventArgs e)
{
if (Page.IsPostBack)
{
if (Session["id"] != null)
{
string id= Session["id"].ToString();
GenerateDynamicControls(id);
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
Session["id"] = null;
}
protected void Button1_Click(object sender, EventArgs e)
{
string id = TextBox1.Text;
Session["id"] = id;
}