ASP.NET Syntax ASP.NET Syntax for Web Controls
Reserves a location in the page control hierarchy for controls that are added programmatically.
Declarative Syntax
<asp:PlaceHolder
EnableTheming = "True | False"
EnableViewState = "True | False"
ID = "string"
OnDataBinding = "DataBinding event handler"
OnDisposed = "Disposed event handler"
OnInit = "Init event handler"
OnLoad = "Load event handler"
OnPreRender = "PreRender event handler"
OnUnload = "Unload event handler"
runat = "server"
SkinID = "string"
Visible = "True | False"
/>
For information on the individual members of this class, see PlaceHolder in the class library.
The PlaceHolder control is a container used to store dynamically added server controls to a Web Forms 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.
For additional information, see the PlaceHolder Class documentation.
The below code snippet demonstrates how to add Web server controls to the PlaceHolder control.
<%@ Page Language = "C#" %>
<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>
<html>
<body>
<asp:PlaceHolder id="PlaceHolder1" runat="server" />
</body>
</html>
<%@ Page Language = "VB" %>
<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>
<html>
<body>
<asp:PlaceHolder id="PlaceHolder1" runat="server" />
</body>
</html> |
|
C# |
VB |
PlaceHolder Class