Render MVC ViewModel without turnkey
This page was created by Hans.karlsen@mdriven.net on 2019-04-22. Last edited by Edgar on 2025-01-20.

MDriven Turnkey does a lot to get a seamless environment for application development.

If you would like to make use of parts of the functionality and render a specific viewmodel from MDriven Framework MVC projects you can do so.

A good way to get started with how to do this is to look into the MDriven Turnkey View called Turnkey/Views/Turnkey/GenericView.cshtml

The trick is to make your MVC model of type VMClass -> @model VMClass, you can then use this construct to render the ViewModel UI:

@Html.Partial(Html.RazorPartialFile());

In order to get the actions for the left side: @Html.DisplayLeftSection()

To get broken constraints: @Html.ValidationSummary(true)

To create VMClass instances you use Eco.ViewModel.Runtime.ViewModelHelper