Tim Scott's Blog

December 31, 2010

MvcContrib.FluentHtml on NuGet

Filed under: FluentHtml, MS MVC — Tim Scott @ 2:55 pm

Okay, I’m a little slow getting this out.  MvcContrib.FluentHtml is now available via NuGet.

Advertisements

December 12, 2010

MvcContrib.FluentHtml With Razor

Filed under: Uncategorized — Tim Scott @ 7:44 pm

MvcContrib.FluentHtml works with the Razor view engine.  To use it now, you have two choices.  You can build from the trunk, or copy this class into your MVC 3 web app.  Then put the following line in your markup file (with your view’s model as the generic parameter):

@inherits MvcContrib.FluentHtml.ModelWebViewPage<MyApp.WebUI.Models.MyModel>

If you decided to put the ModelWebViewPage class into your app directly, of course, adjust the namespace accordingly.  You should also remove any @model directive because the @inherits directive tells the view what the model is.

You probably also want to add this to the namespaces section of your Views web.config file (not the app level web.config):

<add namespace="MvcContrib.FluentHtml"/>

Use the fluent helpers just like you would in an aspx file, except with Razor syntax of course. For example:

@this.TextBox(x => x.FirstName).Id("firstName").Class("someClass").AutoLabel()

Enjoy!

Blog at WordPress.com.