Apply Twitter Bootstrap Validation Style and Message to ASP.NET MVC validation

前端 未结 12 1730
星月不相逢
星月不相逢 2021-01-30 00:57

How can I integrate ASP.NET MVC unobtrusive validation and Twitter Bootstrap? I want to have all those validation messages and styles appropria

12条回答
  •  半阙折子戏
    2021-01-30 01:36

    A nice way of handling this if you're using Bootstrap 2 is...

    Add this to your _Layout.cshtml:

    
    

    These are the posts where I found the code pieces above:

    Integrating Bootstrap Error styling with MVC’s Unobtrusive Error Validation

    Twitter Bootstrap validation styles with ASP.NET MVC

    MVC Twitter Bootstrap unobtrusive error handling


    UPDATE

    Right now I needed to do the same when using Bootstrap 3. Here's the modifications necessary since the class names changed:

    
    

提交回复
热议问题