PlaceHolder Class Home
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.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

'Usage

Dim instance As PlaceHolder

'Declaration

<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class PlaceHolder _
    Inherits Control
<asp:PlaceHolder />
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
Examples

The following code example demonstrates how to dynamically add controls to the PlaceHolder control.

<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >

<head>
    <title>PlaceHolder Example</title>
<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 id="form1" 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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View