Html Conventions in ASP.net MVC
Just today, Jimmy wrote a great post on using HTML conventions in ASP.net MVC using FubuMvc’s core HTML conventions. Go ahead a read it. I’ll wait here.
The problem with this is that it heavily relies on StructureMap (FWIW I love SM, but its overkill here), and doesn’t quite fit into the way ASP.net MVC does things. It also requires a lot of setup. I found this out almost 2 years ago now, and so SchoStack.Web was born. Over the coming posts I will go through what’s included in the library, but here is how you quickly get up and running with the default conventions (these represent the defaults that render lists, dropdowns, checkbox’s which are all ASP.net MVC compliant).
- Create new mvc project.
- install-package schostack.web
- Replace System.Web.Html namespaces in Views/web.config with the following
<add namespace="SchoStack.Web.Html" />
<add namespace="SchoStack.Web.Html.Form" />
- In Application_Start add:
- Thats it.
The following are the three main helpers used to generate all HTML based on your conventions.
All the usual MVC helpers are available as well like ValidationSummary and ValidationMessage.
I’ll try to cover the following things in upcoming posts, but if you have any questions or issues you can ask/raise them on github.
1. Creating your own conventions
2. Closer look at out of the box conventions
3. Validation (Server and Client validation using either FluentValidation and Data Annotations driven off the input model, not the viewmodel)
4. Foreach Loop Helpers
5. Url Generation and Routing