Speed up widget development with Sitefinity MCP server. Learn more...

Add a layout control to a page

The following example adds the layout control to a specified page:

Using the code above you add a layout control to the Header, Content, Right Sidebar, or Footer of a page that inherits from a template that has these controls. The layout control uses the template control as a placeholder. Thus, you are able to break an entire row into columns.

To place a layout control in a placeholder, you first need to find that placeholder. Depending on the template control, you can use the Placeholders collection from the control itself or select the Id value from the control Properties collection.
Then, you initialize the PageManager and based on the page Id you get the page data. To add a layout control, you must create the temp draft of the page. To do this, you use the EditPage method and specify the Id of the page. Then, you create the layout control using the CreateControl<PageDraftControl> method of the PageManager. You then specify all the necessary properties for the layout control (the caption, object type, placeholder, and so on). You set the default permissions by calling SetControlDefaultPermissions method. Then, you add the control to the temp draft page and call CheckIn to get the master. Finally, you publish the page using the WorkflowManager class and pass the required parameters to the MessageWorkflow method.

NEW TO SITEFINITY?

Want to learn more?

Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.

Get started with Integration Hub | Sitefinity Cloud

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.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting your Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.

Was this article helpful?