asp.net.ph

Skip Navigation Links

PlaceHolder Control Syntax

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

For information on the individual members of this class, see PlaceHolder in the class library.

Remarks

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.

Syntax Example

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>
  C# VB

See Also

PlaceHolder Class



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note