Thursday, October 7, 2010

ASP PlaceHolder Control

A Placeholder as its name implies – it is a placeholder for controls or objects.

To see how it works, insert a PlaceHolder control into your page and then add controls to it from your server-side code in the manner shown below.

.aspx

<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

.cs

Label lblMessage = new Label();
lblMessage.Text = "Hello World I am Cool";
PlaceHolder1.Controls.Add(lblMessage);

Here we are creating a new instance of Label control and adding it to placeholder control. You can add more than one control to a single instance of a PlaceHolder control.

Thanks
Emmaneale Mendu
Web Developer.

No comments:

Post a Comment