Integrating Twitter Bootstrap with Asp.net MVC 3 forms

后端 未结 6 1725
有刺的猬
有刺的猬 2021-01-31 09:59

I am using Asp.net MVC 3 and Twitter Bootstrap. What I want is to integrate both of them. The big problem for me is forms. I am using the HtmlHelper and it is a pro

6条回答
  •  无人及你
    2021-01-31 10:23

    A bit late answer, but I'll propose a better solution and you should totally accept my answer ;)

    Use TwitterBootstrapMVC.

    With a single line of code it will generate exactly the html you need:

    @Html.Bootstrap().ControlGroup().TextBoxFor(x => x.Field)
    

    For Global error all you need to write is:

    @Html.Bootstrap().ValidationSummary()
    

    ... it will generate an alert div with all errors listed in it. Notice that for client side validation it needs some JavaScript for things to be styled properly.

    On top of that it will take care of all the unobtrusive validation tags for you. It also offers fluent syntax, that enables full customization of the inputs/labels...

    Check it out!

    Disclaimer: I'm the author of TwitterBootstrapMVC As of Bootstrap 3 (and TwitterBootstrapMVC 3) TwitterBootstrapMVC requires a licence for usage.

提交回复
热议问题