'Does Sitecore 9.3 Helix support ASCX sub layouts

Does Sitecore 9.3 Helix support ASCX user control referred in sub layout, if so, could you please share any reference?



Solution 1:[1]

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);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kate Orlova