PlaceHolder Class
A container to store dynamically added server controls on the Web page.
For a list of all members of this type, see PlaceHolder Members.
System.Object
System.Web.UI.Control
System.Web.UI.WebControls.PlaceHolder
[Visual Basic] Public Class PlaceHolder Inherits Control [C#] public class PlaceHolder : Control [C++] public __gc class PlaceHolder : public Control [JScript] public class PlaceHolder extends Control
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
Use the PlaceHolder control as a container to store dynamically added server controls to the Web page. The PlaceHolder control does not produce any visible output and is only used as a container for other controls on the Web page. You can use the Control.Controls collection to add, insert, or remove a control from the PlaceHolder control.
Example
[Visual Basic, C#] The following example demonstrates how to dynamically add controls to the PlaceHolder control.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script runat="server"> Sub Page_Load(Sender As Object, e As EventArgs) Dim myButton As HtmlButton = New HtmlButton() myButton.InnerText = "Button 1" PlaceHolder1.Controls.Add(myButton) myButton = New HtmlButton() myButton.InnerText = "Button 2" PlaceHolder1.Controls.Add(myButton) myButton = New HtmlButton() myButton.InnerText = "Button 3" PlaceHolder1.Controls.Add(myButton) myButton = New HtmlButton() myButton.InnerText = "Button 4" PlaceHolder1.Controls.Add(myButton) End Sub </script> </head> <body> <form runat="server"> <h3>PlaceHolder Example</h3> <asp:PlaceHolder id="PlaceHolder1" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script runat="server"> void Page_Load(Object sender, EventArgs e) { HtmlButton myButton = new HtmlButton(); myButton.InnerText = "Button 1"; PlaceHolder1.Controls.Add(myButton); myButton = new HtmlButton(); myButton.InnerText = "Button 2"; PlaceHolder1.Controls.Add(myButton); myButton = new HtmlButton(); myButton.InnerText = "Button 3"; PlaceHolder1.Controls.Add(myButton); myButton = new HtmlButton(); myButton.InnerText = "Button 4"; PlaceHolder1.Controls.Add(myButton); } </script> </head> <body> <form runat="server"> <h3>PlaceHolder Example</h3> <asp:PlaceHolder id="PlaceHolder1" runat="server"/> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI.WebControls
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web (in System.Web.dll)
See Also
PlaceHolder Members | System.Web.UI.WebControls Namespace | System.Web.UI.Control | Control.Controls