First time at GK Digital?

GK Digital is an online, collaborative learning platform built from the ground up to be a superior learning experience on the web. It is self-paced and supported by instructors and peers. GK Digital is professional training in the 21st century, from Global Knowledge.
Task: Build composite views

A major focus of ASP.NET MVC is in building maintainable code. Your MVC code is much more testable than the previous version of ASP.NET. There is clean separation between models, views, and controllers, and so on.

However, it is easy to overlook building maintainable code inside your razor views. They can quickly become scrambled messes of code and HTML.

Common problems found in razor files include:

  • Code / HTML duplication
  • Very long, monolithic razor files
  • Lack of razor code readability
  • Controller code doing too much work to support the views

just to name a few.

This task covers partial views and child actions. Together, these two features of MVC allow you to refactor your razor views into clear and maintainable parts of your application.

In addition to these obvious ways to leverage them, we will also see that they can be combined with AJAX in extremely simple ways to actually improve the performance of your application for page load times.

Finally, if you are coming to MVC from ASP.NET WebForms, you may be wondering (or screaming!) where are all the drag-and-drop controls? In MVC we don’t use drag-and-drop in the same way. But, using partial views and child actions can be roughly thought of as user controls.

System.InvalidOperationException: The model item passed into the dictionary is of type 'LearningLine.Interface.ICourse[]', but this dictionary requires a model item of type 'LearningLine.Mongo.Course[]'. at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) at System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) at RazorGenerator.Mvc.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) at ASP._Views_Tasks_ShowPublic_cshtml.Execute()

Preview any course on GK Digital for free.

Just choose a course from our catalog and then press preview course for free.