Render MVC ViewModel without turnkey

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 you can do so.

This is how turnkey does it internally: internal static class MvcRazorPartialViewShared { internal static string RenderRazorPartial(ViewModel.Runtime.ViewModel viewModel) { StringBuilder sb = new StringBuilder(2048); // Building big things! // IMPORTANT! The Using and statements should match the one in the main page! sb.AppendLine("@using Eco.ViewModel.Runtime"); sb.AppendLine("@using Eco.MVC"); sb.AppendLine("@using StreamingAppGenericAPIAndControllers"); sb.AppendLine("@model VMClass"); RazorControlRenderer razorRenderer = new RazorControlRenderer(); if (RenderSettings.CheckUseCSSGrid(viewModel)) { CSSGridViewUICreator cssGridViewCreator = new CSSGridViewUICreator(razorRenderer, sb); ViewModelRTCreator.CreateDataAndUI(null, cssGridViewCreator, viewModel); } else { BootstrapViewUICreator bootstrapViewCreator = new BootstrapViewUICreator(razorRenderer, sb); ViewModelRTCreator.CreateDataAndUI(null, bootstrapViewCreator, viewModel); // Create UI delegating work to UICreator } return sb.ToString(); } }

This page was edited 79 days ago on 02/10/2024. What links here