Forum


HomeHomePremiumPremiumDevelopmentDevelopmentNesting Razor Controls within a DNN ModuleNesting Razor Controls within a DNN Module
Previous
 
Next
New Post
9/25/2015 9:36 AM
 

Hello,

Does anyone know how to render html from a razor file from within another razor file? In other words how to nest Razor Controls.

I am new to Razor but thought @Html.Partial would do the trick but that doesn't seem to be supported in DNN (I hope I'm mistaken). Is there another way to do this? i.e. The equivalent of:
@Html.Partial("~/controls/MyControl.cshtml", Model);

I assume this would merge the Model object properties with the razor file and write the output to the containing file. But I don't think this is available in DNN's Razor version as I can't get Html.Partial in the intellisense.

 

Best Regards,

Steve


 
New Post
9/25/2015 3:41 PM
 

OK I got a tip to use RenderPage, for anyone who's interested, say you have two Razor templates razor1.cshtml and razor2.cshtml, where the first template needs to pass an object variable 'Model' which has a property 'Title', to the 2nd template.

Then in Razor1.cshtml use:
@RenderPage("Razor2.cshtml", new { data = Model });

In Razor2.cshtml use:

<h1>@PageData["data"].Title</h1>
OR
@{var SomeValue = PageData["data"];}
<h1>@SomeValue.Title 2</h1>

 

All the best,

 

Steve

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentNesting Razor Controls within a DNN ModuleNesting Razor Controls within a DNN Module



Try FREE
30 days money back guaranteed