I have a page with 3 users controls and I want to show one user control at a time.
but I’m confused between using the user control visibility property (true,false) or by loading the user control at run time (load a control when click a button and add it to page)
I need your advice
I would suggest you to switch visibility instead of loading dynamically. That’ll make things a lot easier.
On this way you don’t need to
Remember:
Visible="False"does also mean that it will not even exist on client-side as html, so you don’t need to be afraid of creating unnecessary traffic.Rule of thumb: Create controls in ASP.NET dynamically only when the number of controls is unpredictable on compile time.
But even if it’s unpredictable because you get this information from dbms you should consider to use a Data-Bound Control instead(f.e.
GridVieworRepeater).So only a few use cases remain where you need dynamical controls, for example
SessionorViewState