Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Controls When to set the value of controls
Message
 
To
27/07/2009 19:19:20
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Application:
Web
Miscellaneous
Thread ID:
01414924
Message ID:
01415017
Views:
43
>Hi All,
>
>I have created a couple of user controls that I want to dynamically add to a page. The first issue is I was under the impression I had to set the value I wanted in my controls within the Page_PreRender as opposed to the Page_Load event. When the Page PreRender fires, my controls are still null. What is the common wisdom of when to set my controls values?

Page_Load. PreRender happens too late.

>The second question is can I place a User Control in a PlaceHolder? It doesn't throw any exceptions, but doesn't display. I need to place one of two controls in a specific location on my page and don't know which control until the data is retrieved but before the page is loaded. What is the best way to do this?

I'd think strongly about whether dynamically added controls were really necessary, or if you could just get away with putting multiple controls on the page and selectively making them visible/invisible. It can be a PITA to get the eventing correct when you add controls dynamically and it's the kind of thing you might not notice immediately. If you really think you need to go this route, I can follow up with more info (for example, you'll definitely want to use a placeholder for a dynamically added control).
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform