Stores dynamically added server controls on the Web page.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Visual Basic (Declaration)
Public Class PlaceHolder
Inherits Control
Dim instance As PlaceHolder
public class PlaceHolder : Control
public ref class PlaceHolder : public Control
public class PlaceHolder extends Control
public class PlaceHolder extends Control
Use the PlaceHolder control as a container to store server controls that are dynamically added to the Web page. The PlaceHolder control does not produce any visible output and is used only as a container for other controls on the Web page. You can use the Control.Controls collection to add, insert, or remove a control in the PlaceHolder control.
The following code example demonstrates how to dynamically add controls to the PlaceHolder control.
<%@ 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>
<%@ 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>
System.Object
System.Web.UI.Control
System.Web.UI.WebControls.PlaceHolder
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
.NET Framework
Supported in: 2.0, 1.1, 1.0