Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamically Loaded User Controls

Reply
Thread Tools

Dynamically Loaded User Controls

 
 
Rich
Guest
Posts: n/a
 
      12-15-2005
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net 1 05-26-2004 12:42 AM
Events in dynamically loaded user controls Danny Bloodworth ASP .Net 2 11-21-2003 07:23 AM
Dynamically loaded User Controls - problem with button_click event Tim T ASP .Net 7 11-01-2003 05:44 PM
Output Caching for Dynamically Loaded User Controls Teo Lachev ASP .Net 0 07-01-2003 12:16 PM



Advertisments