The PlaceHolder Control

Just as the Literal control allows you to inject HTML into a page at runtime, the PlaceHolder control allows you to inject new controls into a page, at a specific location, at runtime. Imagine that you have a table full of links, and you want to insert the series of links into a page between to static paragraphs of text. You don't want to render the entire page at runtime, only the list of links.

No problem—the PlaceHolder control comes to the rescue (working with its pal, the Literal control). We've used this technique to generate the content for Main.aspx in the sample project shown in Figure 22.5. At design time, there's really nothing on this page except a Label control and a single PlaceHolder control (see Figure ...

Get ASP.NET Developer's JumpStart now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.