Does Sitecore 9.3 Helix support ASCX user control referred in sub layout, if so, could you please share any reference?
Asked
Active
Viewed 61 times
1 Answers
4
Yes, it does support. In fact, this will work regardless of whether you follow Helix principles or not.
I guess that you want to mix renderings with sub layouts on a Sitecore MVC layout.
If your ASCX sub layout does not contain any postback logic and/or does not have another sub layout inside it then the easiest way will be to declare it in a View Razor file as follows:
@Html.RenderSitecoreSubLayout("~/Layouts/Sublayouts/YourSubLayout.ascx")
Alternatively, you can generate the inner sub layout at a code level and add it to a placeholder to get it rendered correctly, for example:
Sublayout yourSublayout = new Sublayout
{
Path = "~/Layouts/Sublayouts/YourSubLayout.ascx",
DataSource = yourItem,
Cacheable = true,
VaryByData = true,
VaryByParm = true
};
phYourPlaceholder.Controls.Add(yourSublayout);

Kate Orlova
- 3,225
- 5
- 11
- 35