Simple Dynamic Controls Demo

This demo illustrates how to dynamically add a Label control to an ASP.NET Web page using a PlaceHolder. Note that the "Hello, World" string is between the <HR>s and not at the end of the HTML content, as it was in the first live demo.


Hello, World!


Source Code
<script language="vb" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    sub Page_Load(sender as Object, e as EventArgs)
      Dim lblMessage as New Label()
      lblMessage.Text = "Hello, World!"
      lblMessage.Font.Bold = True
      
      PutLabelHere.Controls.Add(lblMessage)
    end sub
  End Sub
</script>

<html>
<body>
<h1>Simple Dynamic Controls Demo</h1>
This demo illustrates how to dynamically add a Label control to an ASP.NET Web page using a PlaceHolder.
Note that the "Hello, World" string is between the <code><HR></code>s and <i>not</i> at the end
of the HTML content, as it was in the <a href="dynCtrls1.aspx">first live demo</a>.
<p><hr><p>
<asp:PlaceHolder runat="server" id="PutLabelHere" />
<p><hr><p>

...
	


[Return to the article]