Add elements to Aspx page from vb.net code? Thanks.

S

Shapper

Hello,

How to I create add Div with an Asp:Label and an Asp:DropDownList inside
it to my aspx page from my vb.net code?

Thanks,
Miguel
 
G

Guest

Could you use an asp:panel instead? It does virtually the same thing and you
can create child controls within it, hide it (and therefore everyting inside
it) etc.
 
S

Shapper

Hi,

Sure an Asp:panel would be ok to.

So how can I create something like this:

<Asp:panel>
<Asp:Label></Asp:Label>
<Asp:DropDownList></Asp:DropDownList>
</Asp:panel>

Thanks,
Miguel
 
A

Andrea Zani

Shapper said:
Hello,

How to I create add Div with an Asp:Label and an Asp:DropDownList
inside it to my aspx page from my vb.net code?

Thanks,
Miguel

Use PlaceHolder:
<html><body>
....
<asp:placeholder id="xxx" runat="server" />
....
</body></html>

And the code:
dim lab as new Label
lab.ID="mylabel"
xxx.Controls.Add(lab)
dim ddl as new DropDownList
ddl.ID="myddl"
xxx.Controls.Add(ddl)

If you want insert text:
xxx.Controls.Add(new Literal("cip cip cip"))
 

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,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top