creating webform controls at run time

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
 
S

Steve C. Orr [MVP, MCSD]

Code along these lines should do what you want:

Dim lbl as New Label.
lbl.Text="Whatever"
SomePanel.Controls.Add(lbl)
 
R

ray well

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
 
S

Steve C. Orr [MVP, MCSD]

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.
 
W

WJ

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top