Hi,
I have a razor file that contains code that I'd like to include in several skin files but I'm having a hard time figuring out how to include it.
I tried render page as such
<section> <div id="ContentPane" runat="server"></div> </section>
@RenderPage("_GetArticles.cshtml")
But this gives a 500 server error.
I've also tried this:
<section> <!-- FEATURED CONTENT START --> <div id="ContentPane" runat="server"></div> <!-- FEATURED CONTENT END --> </section>
<% @RenderPage("_GetArticles.cshtml") %>
It does the same. What is the proper syntax for this?
Well, the Skin is Webforms based so you cannot include Razor by default AFAIK. There are options to use Razor in a DNN Extensions though.
There are a number of ways to include/use Razor. It just depends on the module(s) you're using/building, but Timo is right. For the foreseeable future, the theme engine is and will be based on webforms. Luckily, nearly anything you'd want to do using Razor is still available. You'd just be using a slightly different syntax, for now.
Posted By Faith Coder on 11/16/2023 6:35 PM Thanks Tim, That's a bummer. We are using the RazorHost module and RenderPage works in there, was just hoping to be able to do the same in a skin. That way the code can be placed in one skin file instead of numerous Razor ones. It's a maintenance thing. We're trying to stay away from 3rd party modules as much as possible and stick to the core. With the exception of your stylehelper skin object of course. That's been very helpful and we've had no issues with it. Thankfully with the core's Razorhost module we can create forms so no need for form builder modules anymore. It's been a real gamechanger for us. We really don't need too many third party mods now with that in the arsenal.
As Will said you can include C# in a Theme, and the code should not be much different. For those landing on this page wondering how the Open Content Skin Object works, here's an example: https://github.com/40fing...10.00-OC-Skin-Object
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.