Viewing source for Recipe0307cs.aspx

<%@ Page language="c#" %>
<script runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
	// Initialize Placeholder
	PlaceHolder1.Controls.Clear();
	switch (DropDownList1.SelectedIndex)
	{
		case 0:
			AspNetCookbook.Recipe0301cs SimpleText = new AspNetCookbook.Recipe0301cs();
			SimpleText.Text = "This is the simple text control from Recipe 3.01.";
			PlaceHolder1.Controls.Add(SimpleText);
			break;
		case 1:
			AspNetCookbook.RainbowLabel RainbowText = new AspNetCookbook.RainbowLabel();
			RainbowText.Text = "This is the RainbowText control from Recipe 3.02.";
			PlaceHolder1.Controls.Add(RainbowText);
			break;
	}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html>
  <head>
    <title>Recipe0307</title>
  </head>
  <body>
    <form id="Recipe0307" method="post" runat="server">
				<asp:DropDownList id="DropDownList1" runat="server">
					<asp:ListItem Value="Simple Text Control (Recipe0301)">Simple Text Control (Recipe0301)</asp:ListItem>
					<asp:ListItem Value="RainbowLabel (Recipe0302)">RainbowLabel (Recipe0302)</asp:ListItem>
				</asp:DropDownList>
				<asp:Button id="Button1" runat="server" Text="Select" onclick="Button1_Click"></asp:Button>
			<p>
				<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
			</p>
     </form>
  </body>
</html>