Hiding user controls vs dynamic creation


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Hiding user controls vs dynamic creation

  1. #1
    Senkwe Guest

    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

  2. #2
    Webbie Guest

    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.





  3. #3
    Senkwe Chanda Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center