R
Rich
Hi,
I have been looking into how dynamical user controls work on asp.net web
pages.
This simple code is used to load and add the control to the page, which also
has a Label control.
TextBox tb = new TextBox();
this.Label1.Controls.Add(tb);
This code has been tried in both the 'Page_Load' and the 'OnInit' events of
the Page.
(I also have a button on the page to test if viewstate is maintained after a
postback.)
If I add text to the control ( after the page is loaded) and then click the
button to do a postback the text always stays the same.
Can someone tell me why the viewstate is maintianed in both cases? I thought
loading the control in the 'OnInit' event was the correct place to load
controls and to maintian its viestate?
Cheers
I have been looking into how dynamical user controls work on asp.net web
pages.
This simple code is used to load and add the control to the page, which also
has a Label control.
TextBox tb = new TextBox();
this.Label1.Controls.Add(tb);
This code has been tried in both the 'Page_Load' and the 'OnInit' events of
the Page.
(I also have a button on the page to test if viewstate is maintained after a
postback.)
If I add text to the control ( after the page is loaded) and then click the
button to do a postback the text always stays the same.
Can someone tell me why the viewstate is maintianed in both cases? I thought
loading the control in the 'OnInit' event was the correct place to load
controls and to maintian its viestate?
Cheers