Bootstrap + Mvc: Controlling Template Rendering

As we explore Twitter’s CSS and JavaScript library in Asp.Net MVC, we’re starting to get into the meat of “Bootstrapping” our site, and exploring control templates. If you’d like to keep up with the project code, you can check out the repository on GitHub. With a few clean-ups on the create form, our site is now looking like this:

image

When you create display and editor templates to override the default templates offered for types by the Mvc Framework, you don’t always want those templates used. How do you get around this?

Change the name of your template to something that doesn’t match an existing type, then use the UIHint attribute to coerce the property into using your template when being rendered.  Nice!  Here’s a property with the correct attributing:

[Display(Name = "VIP - Skip the Line")]
[UIHint("SwitchedBoolean")]
public bool CanSkipLine { get; set; }

 

You can follow the posts in this series from the main page, where I’m curating the links to the instalments of the series.

Cheers!