PlaceHolder
The PlaceHolder component is meant to emulate the asp:PlaceHolder control in markup and is defined in https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.placeholder?view=netframework-4.8
PlaceHolder is a simple container that renders NO wrapper element - it only renders its child content. This is useful for conditionally showing/hiding blocks of content.
Blazor Features Supported¶
ChildContent- the content to render inside the PlaceHolderVisible- controls whether the content is rendered
Key Characteristic¶
Unlike Panel, PlaceHolder renders only its children with no wrapper element. This makes it ideal for:
- Conditional rendering of content blocks
- Grouping content without affecting HTML structure
- Dynamic content placeholders
Usage Examples¶
Basic Usage¶
Renders as:
Conditional Visibility¶
WebForms Syntax¶
<asp:PlaceHolder
EnableTheming="True|False"
EnableViewState="True|False"
ID="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
runat="server"
SkinID="string"
Visible="True|False"
/>
Migration Notes¶
When migrating from Web Forms:
- Remove
asp:prefix andrunat="server" - The
IDproperty is not rendered (use Blazor's@reffor component references) - Use for conditional rendering of content blocks