Skip to main content
Home  ›  Docs › Feature

Partial Views for Re-Using Razor Templates @RenderPage

Warning ⚠️: New Docs Available

These are old docs and we haven't found the time to completely move them. You will find comprehensive new docs on docs.2sxc.org.

Introduced in Version 06.00.00
Demos of this feature

So you can create various razor-views like...

  1. List
  2. Details
  3. Filtered list

and use these as sub-templates for another script. This is especially practical if you want to re-use parts of templates.

How does it work? Here's an example how a main script could change Razor-Views based on a URL-Parameter 

@if (Request.QueryString["feature"] == null)

{

       @RenderPage("_2SexyContent Feature - List.cshtml");

}

else

{

       @RenderPage("_2SexyContent Feature - Details.cshtml", Request.QueryString["Feature"]);

}

 

This could be used as follows

  1. You could create single-page Apps, where the other views are on the same page
  2. The main Content-Element of this module could have configuration-parameters, and this Content always be available in the sub-pages. You could still do things like @Content.Title
  3. You could also create apps which show the same data, but just vary the template
  4. You can re-use partial templates (for example a sub-template showing just one person, which is used at the bottom of a blog-app)

Try the View Management Demo App to discover it or read more in my blog post about this.

Tags for this feature
Apps new in 6.x Razor Linking