共用方式為


PlaceHolder Web Server Control Overview

The PlaceHolder control lets you place an empty container control in the page and then dynamically add child elements to it at run time.

This topic contains:

  • Background

  • Code Examples

  • Class Reference

Background

The PlaceHolder Web server control lets you place an empty container control within the page and then dynamically add, remove, or loop through child elements at run time. The control renders only its child elements; it renders no markup of its own.

For example, you might want to have a variable number of buttons appear on a Web page, depending on options selected by users. That way, users are not confronted with potentially confusing choices that are either unavailable or not relevant to their individual needs. You can create the buttons dynamically and then add them as children of a PlaceHolder control.

Back to top

Code Examples

How to: Add PlaceHolder Web Server Controls to a Web Forms Page

How to: Add Controls to an ASP.NET Web Page Programmatically

Back to top

Class Reference

The following table lists the classes that relate to the PlaceHolder control.

Member

Description

PlaceHolder

The main class for the control.

PlaceHolderControlBuilder

The class that works with the parser to build a PlaceHolder control. To create a custom control builder for a PlaceHolder-derived control, you to inherit from this class.

Back to top

See Also

Other Resources

Adding ASP.NET Controls Programmatically