Question: I'm currently working on a website using c# and asp.net. For this purpose, I need to create dynamic controls but I enconter some issues. I already read official documentation and searched for lots of tutorial but unfortunately, no one allowed me to fix this problem.

Here is a very simplified example of what I'm trying to do;

```
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
        CreateControls();
    else
        UpdatePage();
}

protected void CreateControls()
{
    Button button1 = new Button();
    button1.ID = "_Button1";
    button1.Text = "Button1";
    button1.Click += new System.EventHandler(_ClickEvent);
    _Panel.Controls.Add(button1);

    Button button2 = new Button();
    button2.ID = "_Button2";
    button2.Text = "Button2";
    button2.Click += new System.EventHandler(_ClickEvent);
    _Panel.Controls.Add(button2);
}

protected void UpdatePage()
{
    Button button1 = ((Button)_Panel.FindControl("_Button1"));
    button1.Text = "I went through UpdatePage and changed";

    Button button2 = ((Button)_Panel.FindControl("_Button2"));
    button1.Text = "I went through UpdatePage and changed";
}

protected void _ClickEvent(object sender, EventArgs e)
{

}

```

The aim here would just be to change the buttons' text when clicking on one of them. "Page\_Load" method is correctly called as well as the "UpdatePage" one, but in the latter, Button1 and Button2 controls have disappeared (they are not in the panel controls anymore) and an NullPointer exception is obviously raised.

Would anybody have an explanation ? I know I probably missed something about page life cycle but could not find any clear solution anywhere.

Thanks a lot !

Answer: 
There should have been a second window opened by default with the title "Console". If it didn't show up, or you accidentally closed it, you can open it up again by checking the Console option in the Window menu.
Find a "single line" button and manually keep going through your code. It worked for me.