Logo
Logo
  • Blazor CMS Home
  • Oqtane Tutorials
  • Blazor CMS Home
  • Oqtane Tutorials
Oqtane Tutorials
Oqtane Tutorials

Reuse Templates and Code Tutorials

Tutorial Home › Reuse
Working with 😃 Emojis / Emoticons
#1 Reuse Code and Razor Templates
Code - Function and Similar Helpers
The samples can differ based on your Razor base class or if you're running an old version.
Selected: Strong-Typed (2sxc 17.06+) Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Requirements
  • 2sxc 12.08
Related
  • Reuse Shared Templates with Html.Partial and MyModel

Reuse Code and Razor Templates

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. Func<dynamic, dynamic> micro-helpers are ideal for small sub-templates - see docs

When Using other Razor or Code, you should also know:

  1. Model is the typed object used in sub-pages to receive parameters from the caller - see docs
  2. MyModel is the generic object used in sub-pages to receive parameters from the caller - see docs
  3. To get a helper, just use new Helper(...) or GetService<HelperType>()
  4. GetCode(...) to create objects from .cs files sometimes still works, but is not recommended - see docs

 

Working with 😃 Emojis / Emoticons
#1 Reuse Code and Razor Templates
Code - Function and Similar Helpers
  • 2sic internet solutions
  • Langäulistrasse 62, 9470 Buchs SG, Switzerland
  • +41 81 750 67 77
Login