Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
In Sitefinity you can programmatically create a page and populate it with controls. In some cases you might need to get a specific layout control in your page template using the set css class attribute. You might need to change the template layout control markup, as well.
We get the template layout controls and then using a html parser we get the control attributes. This is not a fast procedure but it should not be considered to find and change layout controls programmatically very often.
We get the layout controls and process them:
TemplateDraftControl GetLayoutControl(PageManager manager,
, TemplateDraft draftTemplate)
var layoutControls = draftTemplate.Controls;
var ctrlData = manager.GetControl<TemplateDraftControl>(control.Id);
var layProp = ctrlData.PropertiesLang.Single(p => p.Name ==
var layout = layProp.Value;
) && !layout.EndsWith(
var found = TryFindControl(ctrlData, layout, @
layout = GetDefaultLayoutControlsHtml(ctrlData, layout);
I have created a helper class containing methods for getting the layout control and getting and setting its markup.
var manager = PageManager.GetManager();
var helper =
var mycontrol = helper.GetLayoutControlFromPage(manager,
(mycontrol.Id != Guid.Empty)
var html = helper.GetControlHtml(mycontrol);
// change the html of the layout control
"<span>This is from debug</span>"
helper.ChangeControlHtml(manager, mycontrol, html);
The full source code could be downloaded from GitHub here.
Nikola Zagorchev is a Tech Support Engineer at Telerik. He joined the Sitefinity Support team in March 2014.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.