-
Hiding user controls vs dynamic creation
Hi all, I need a second opinion on this. Recently I've been struggling with
trying to load user controls dynamically. Simple right. Well not if those
user controls also host other user controls that are loaded dynamically.
It's technically possible but all solutions I've seen so far haven't worked
and they have been hacks. The main problem with loading user controls dynamically
is keeping track of view state and wiring up events.
Now, one workaround I thought of was loading all the user controls at compile
time (so that they are actually part of the page) and hiding/showing the
desired controls depending on user input. I had thought that the resultant
html source produced would end up becoming bloated with hidden controls.
A quick test however, showed that the source ends up excluding all invisible
controls, ie they are simply not rendered. So the resultant page is NOT bloated.
To prevent too much work being done on the server however, I thought you
could test to see if the control was visible in which case you could safely
call your daa binding code for example, and if not, you simply do nothing
when the control loads.
Well, what do yu guys think? Is this how you do it as well? I'd like to hear
pros and cons.
Regards
Senkwe
-
Re: Hiding user controls vs dynamic creation
I, too, have had problems rendering User Controls dynamically. Especially
when I have to pass in values to that user control and alter the data/controls
within the user control via the passed in values.
Your idea of controlling the controls' visibility seems sort of thrown together.
If you do follow that approach, wouldn't you rather use the Enabled property
versus the Visible property?
Just an idea. Good luck.
-
Re: Hiding user controls vs dynamic creation
"Webbie" <simonscr@jmu.edu> wrote:
>
>I, too, have had problems rendering User Controls dynamically. Especially
>when I have to pass in values to that user control and alter the data/controls
>within the user control via the passed in values.
>
>Your idea of controlling the controls' visibility seems sort of thrown together.
> If you do follow that approach, wouldn't you rather use the Enabled property
>versus the Visible property?
>
>Just an idea. Good luck.
>
>
>
>
Yeah the problem with that is that the control ends up being rendered. For
example, if I set Enabled="false" for a text box on a web form, it still
shows up on the form, but it is greyed out. If it is invisible, it is not
rendered at all and thus does not even appear as part of the page source.
Senkwe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks