Skip to main content

Reuse Templates and Code Tutorials

Tutorial HomeReuse

Reuse templates and code

This will show you how to place partial templates into separate files, and how to put functions you need in many places in separate files as well. It focuses on:

  1. @Html.Partial(...) to render another page (older versions of 2sxc used @RenderPage(...)) - see docs
  2. DynamicModel is the object used in sub-pages to receive parameters from the caller - see docs
  3. CreateInstance(...) to create objects from .cs files - see docs

Reuse Shared Stuff Examples

  1. Reuse template with @Html.Partial and DynamicModel
  2. Reuse Razor Helpers (mini-templates) with CreateInstance
  3. Reuse a function library CreateInstance
  4. Reuse code with .cs files
    CreateInstance is enhanced in 2sxc 10.01 to support .cs files to share code across Razor files and WebApi Controllers.

Deprecated Features

This shows / documents features which work, but are not recommended any more:

  1. Split Razor Templates into C#-Code and Template deprecated
    Now you can split out complicated C# code so designers don't have to worry about it.