creating webform controls at run time

  • Thread starter Thread starter ray well
  • Start date Start date
R

ray well

hi,

is it possible to create controls in a webform at run time in the Page_Load
event.

i would like to create a calculated amount of labels as the page loads,
place them at certain places on the page, and place some data there, after
getting some info from a backend database.

is this possible? i would appreciate a bit of code.

thanks

ray
 
Code along these lines should do what you want:

Dim lbl as New Label.
lbl.Text="Whatever"
SomePanel.Controls.Add(lbl)
 
thanks steve,

is there a way to move the control to a specific location on the panel or
page, i could not find any location property? how would i do it?

thanks

ray
 
Your best bet is to put the panel where you want in advance, then add the
control to it at design time.
You can also use placeholder controls.
 
Very clumsy but it can be done. Example: At design time, build a nested
table, hide it (Visible=false). At run time, assign the newly created WC to
a specific pre-designed cell of a selected Table, make sure set Visible to
True.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top