Generating webcontrols in runtime

A

Annick Van Hoof

Hi,

I would like to make an ASP.NET page that dynamically obtains information
form a database and creates an input screen on the fly. This would mean I
would need a way to create ASP.NET webcontrols on the fly.

Could this be done ? If so, how ? Has anyone an example to do this ?

Thanks in advance,

Annick
 
Y

Yuri Belenky

You could choose the following way:
At the ASPX page


<%if (EditBoxRequired()){%>
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 544px; POSITION:
absolute; TOP: 136px"
runat="server"></asp:TextBox>
<%}%>


And EditBoxRequired() function at the code behind. You could check you
database in this function and check do you need this editbox. Do not miss
that this function should be marked public
 
J

Joe

Use Page.Controls.Add([standaradcontrol])..... or for ascx's use
Page.LoadControl("[yourcontrol.ascx"])....

Joe
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top