Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationSummary not rendered in Bootstrap styling #45

Open
roryprimrose opened this issue Dec 29, 2012 · 3 comments
Open

ValidationSummary not rendered in Bootstrap styling #45

roryprimrose opened this issue Dec 29, 2012 · 3 comments
Milestone

Comments

@roryprimrose
Copy link
Contributor

I am using @Html.ValidationSummary(true) but it is rendering in its default div/ul/li styling.

I don't have any integration with LESS yet, so the solution at http://stackoverflow.com/questions/13867307/show-validationsummary-mvc33-as-alert-error-bootstrap is a good option for me ATM.

I have added a partial view as indicated in the SO link.

@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Any()) 
{ 
   <div class="alert alert-error"> 
      <a class="close" data-dismiss="alert">×</a> 
      @Html.ValidationSummary(true)
   </div>
} 

I then added this partial view in the bootstrap layout file under the reference to

        @Html.Partial("_alerts")
        @Html.Partial("ValidationSummary")

The only thing missing is the styling of the UL which I removed with the following css:

.validation-summary-errors ul
{
    list-style-type: none;
}

It would be nice if this made it into the package. Not sure how you would want to integrated it though.

Cheers,

Rory

@erichexter
Copy link
Owner

That makes a lot of sense... I need to try this out with the runtime
scaffolding.

Eric Hexter

blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter

On Sat, Dec 29, 2012 at 5:05 AM, roryprimrose notifications@github.comwrote:

I am using @Html.ValidationSummary(true) but it is rendering in its
default div/ul/li styling.

I don't have any integration with LESS yet, so the solution at
http://stackoverflow.com/questions/13867307/show-validationsummary-mvc33-as-alert-error-bootstrapis a good option for me ATM.

I have added a partial view as indicated in the SO link.

@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Any())
{

× @Html.ValidationSummary(true)
}

I then added this partial view in the bootstrap layout file under the
reference to

    @Html.Partial("_alerts")
    @Html.Partial("ValidationSummary")

The only thing missing is the styling of the UL which I removed with the
following css:

.validation-summary-errors ul{
list-style-type: none;}

It would be nice if this made it into the package. Not sure how you would
want to integrated it though.

Cheers,

Rory


Reply to this email directly or view it on GitHubhttps://github.com//issues/45.

@erichexter
Copy link
Owner

I started implementing this.. it will need an additional css file to be
included in the package, to handle the override of the mvc default style.

@roryprimrose
Copy link
Contributor Author

Fixed bug in the partial view which wouldn't render errors related to properties (via the true parameter on ValidationSummary)

I now use:

@if (ViewData.ModelState.Any(x => x.Value.Errors.Any()))

@erichexter erichexter added this to the V1 milestone Dec 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants