#3 Reuse Shared Templates with Html.Partial and MyModel
The samples can differ based on your Razor base class or if you're running an old version.
Switch to Strong-Typed (2sxc 17.06+) Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Switch to Strong-Typed (2sxc 17.06+) Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Resources
Reuse Shared Templates with Html.Partial and MyModel
Partial templates are cshtml files which you can use multiple times. Typically they will contain something which you need in many places, like a menu or a data-visualizer which gets data as a parameter, and then creates a different table each time. Here's how to use it with Html.Partial(...).
Passing Parameters/Values
If you pass values to the Razor Control on older Base classes such as Razor14, the parameters arrive on the DynamicModel object.
On the new typed base class RazorTyped it will be in the MyModel object (see examples below)
This uses @Html.Partial to get the file line.cshtml 3 times.
⬇️ Result | Source ➡️
#3 Reuse Shared Templates with Html.Partial and MyModel