Here is an example of how to add a web control to PlaceHolder control.
HTML
<form id="Form1" method="post" runat="server">
<asp:placeholder id="placeHolder" runat="server"> </asp:placeholder>
</form>
CODE BEHIND
Dim newLbl As New Label
newLbl.ID = "Label1"
newLbl.Text = "This is a label control. "
placeHolder.Controls.Add(newLbl)
Dim newBtn As New Button
newBtn.ID = "Button1"
newBtn.Text = "This is a button control. "
placeHolder.Controls.Add(newBtn)
' To remove the controls
placeHolder.Controls.Remove("Label1")
placeHolder.Controls.Remove("Button1")
Cheers!
0 comments:
Post a Comment