System.Web.UI.WebControls


.NET Framework Class Library
PlaceHolder Class

Stores dynamically added server controls on the Web page.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Syntax

Visual Basic (Declaration)
Public Class PlaceHolder
    Inherits Control
Visual Basic (Usage)
Dim instance As PlaceHolder
C#
public class PlaceHolder : Control
C++
public ref class PlaceHolder : public Control
J#
public class PlaceHolder extends Control
JScript
public class PlaceHolder extends Control
Remarks

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.

TopicLocation
How to: Add Controls to an ASP.NET Web Page ProgrammaticallyBuilding ASP .NET Web Applications
How to: Add Controls to an ASP.NET Web Page ProgrammaticallyBuilding ASP .NET Web Applications
How to: Add Controls to an ASP.NET Web Page ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
How to: Add Controls to an ASP.NET Web Page ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
How to: Add PlaceHolder Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications in Visual Studio
How to: Add PlaceHolder Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications in Visual Studio
How to: Add PlaceHolder Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add PlaceHolder Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add PlaceHolder Web Server Controls to a Web Forms Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
How to: Create Instances of ASP.NET User Controls ProgrammaticallyBuilding ASP .NET Web Applications in Visual Studio
How to: Create Templated ASP.NET User ControlsBuilding ASP .NET Web Applications
How to: Create Templated ASP.NET User ControlsBuilding ASP .NET Web Applications
How to: Create Templated ASP.NET User ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Create Templated ASP.NET User ControlsBuilding ASP .NET Web Applications in Visual Studio
Example

The following code 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>
.NET Framework Security

Inheritance Hierarchy

System.Object
   System.Web.UI.Control
    System.Web.UI.WebControls.PlaceHolder
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.
Platforms

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.

Version Information

.NET Framework

Supported in: 2.0, 1.1, 1.0
See Also

Tags :


Page view tracker