In the below thread, the solution for adding @Html.RenderFormStyles() and @Html.RenderFormScripts() in OuterLayout.cshtml was provided.

  • If we have an already existing site and we want to add forms to an existing web page is it required to create an OuterLayout.chtml for the existing one?

  • If yes, what is the solution for an existing site?

I tried adding @Html.RenderFormStyles() and @Html.RenderFormScripts() to the existing .cshtml file without adding an OuterLayout.cshtml as mentioned ABOVE but it did not work. I've added @Html.RenderFormStyles() and @Html.RenderFormScripts() in the head section as below to an existing ERE.Default-SubPage.cshtml but when I ran the page, the scripts did not show up.

    @if (!Sitecore.Context.PageMode.IsExperienceEditor)

@Html.RenderFormScripts() and @Html.RenderFormStyles() do nothing


I think it's all in here: https://doc.sitecore.com/developers/92/sitecore-experience-manager/en/add-a-form-to-a-webpage.html

If you don't have an existing Layout set, you can just create the outer layout and reference it, if you do have one (I often have a 'base'/outter layout which is used by all multi-site layouts), you can just ensure that the correct @using statements and @html.RenderFormXXX() lines are in the appropriate place as per item 6 in that doco and all should be well.

What you're effectively doing is giving yourself the option to NOT have the form styles and form scripts in every single layout if you don't need them to improve performance etc.

If you just want the option to add them to any page and you have only got one layout, maybe it's just easier to add the outter layout and include them on every page and see if you find the performance acceptable or not?

To do that, you just need to create the the "outer" layout file (name it whatever you like). The "inner" layout then is rendered into the @RenderBody() section so you can easily refactor your layout set up to accommodate it yeah?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.