DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

Html.BootStrap().ValidationSummary() - arguments #45

Closed Ajitweb closed 10 years ago

Ajitweb commented 10 years ago

Hi,

Thanks for adding the ValidationSummary helper.

But I think as of now, it does not support the arguments found in Html.ValidationSummary(). ie Html.ValidationSummary(true) ->To hide property errors Html.ValidationSummary("Error Message") ->Display a message before other messages Html.ValidationSummary(true,"Error Message")

Thanks.

DmitryEfimenko commented 10 years ago

Indeed this is the case. You can either submit a pull request with the changes you need or wait till I get around and do it. This might take a while for me since I'm working on integration with Twitter Bootstrap 3 right now.

Ajitweb commented 10 years ago

Thanks Dmitri.

DmitryEfimenko commented 10 years ago

Lets keep the issue open till ValidationSummary gets updated one way or another. I don't want to lose track of it.

paulovin commented 10 years ago

Do you intend on adding any localization support for the default validation messages as well?

DmitryEfimenko commented 10 years ago

I'm have redone ValidationSummary.

Under the hood it will use regular Html.ValidationSummary(), wrapped into a div with class alert alert-danger. The reason I decided to implement it like that is so that unobtrusive validation works with it as well. There is one complication associated with it though. Having a div with class alert alert danger makes the div to always be visible. To solve this (and couple other issues related to client side scripting) I will be providing a javascript file.

The fact that it will use regular Html.ValidationSummary() means that localization will be supported the same way as if you'd use regular helper. If you have any ideas how I can simplify support for localization, please share your thoughts.

megcgo commented 10 years ago

I have a technique to show alerts by using ViewBag.

On the View I use the razor:

@if (!(ViewBag.Error == null)) { <div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> @ViewBag.Error</div> }

Then in the controller, if I set the

ViewBag.Error = "Some error message!"

then the view will display the alert with the message. If I don't set the Viewbag.Error, it will be null and in the view will display nothing.

I can use this with many different alerts.. one for errors, one for info, one for warning... etc. You only need to use Javascript if you want the alerts to dismiss automaticaly(after some time), if not, you can attach the dismiss button to the alert and you dont need extra javascript to show alerts and dismiss them :)

Cheers

DmitryEfimenko commented 10 years ago

ValidationSummary helpers is updated. Notice that it requires some javascript (provided in the documentation page of BMVC site) Be careful with updating to a new version. There are couple of breaking changes. For all changes see CodeProject article The website to download license for TB3 (In case you would like to switch) is www.twitterbootstrapmvc.com