You can add layout controls to Pages and Page Templates. To create a LayoutControl to a Page or PageTemplate, you must:
LayoutControl
PageTemplate
PageControl
TemplateControl
ascx
.ascx
You add the Layout Control to the intended object’s Controls collection. The following example shows how to create a LayoutControl, and then add it to a Page:
Controls
You simply add theLayoutControl to the intended object’s Controls collection. The following example shows how to create a LayoutControl, and then add it to a Page Template:
To query the LayoutControls, you access the Controls collection on the Page or Template to work on those where the ObjectType is LayoutControl.
LayoutControls
When you want to put a widget inside a LayoutControl programmatically, you work with the Placeholders collection of the LayoutControl. The placeholders are the containers that form the docking zones in Sitefinity that allow you to “dock” a widget on them. For example, a LayoutControl whose template defines only a single 100% layout has a single Placeholder object in its Placeholders collection. A LayoutControl with 3 columns has three Placeholders. First, you must locate the Placeholder you want. Since the Placeholders collection is a string [] you use index to get the desired Placeholder. For example:
Then you specify the widget’s placeholder. When you create a new widget that will be added to a Sitefinity page through code, you can supply the placeholder on the page where it will be added. To do this, use the the PageManager.CreateControl<T>()method. The following example shows the creation of a basic ContentBlock and setting its placeholder before adding it to the page:
PageManager.CreateControl<T>()
ContentBlock
The following sample demonstrates:
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important