Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

ima
Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...