How can I dynamically add controls(+ Formatting) to a web form

sureshcd10

Regular
Joined
Dec 25, 2003
Messages
77
How can I dynamically add controls to a web form.Also how can I dynamically control the position(Formatting) on the form with which a control is to be displayed?( Plz provide sample code).
Thanks in advance :confused: :confused: :o
 
I have several pages that controls appear to be created at runtime but they are not. I just set the controls to visible=false until they are needed. Then at runtime it is easy to set visible=true again and vice versa.

.Net doesn't actually send the HTML code for the control to the browser if it is marked as visible=false so it automatically controls the layout. I like it doing it for me:-)

HTH
Eva
 
Use a Place holder

hi ...

Use the placeholder control for alignment and create your dynamic controls within the place holder.

If you are using the controls to postback data, then don't create them outside the page_load method.

If you want to do the control creation, you have to do it before the page framework's SaveviewState method is invoked.

you can override this method using the onPrerender method.
 
Back
Top