Note that there are some explanatory texts on larger screens.

plurals
  1. POShow ValidationSummary MVC3 as "alert-error" Bootstrap
    primarykey
    data
    text
    <p>I want to show a ValidationSummary mcv3 with "alert-error" Bootstrap styling.</p> <p>I'm using a Razor view, and I show model errors with this code:</p> <pre><code> @Html.ValidationSummary(true, "Errors: ") </code></pre> <p>It generates HTML code like this:</p> <pre><code>&lt;div class="validation-summary-errors"&gt; &lt;span&gt;Errors:&lt;/span&gt; &lt;ul&gt; &lt;li&gt;Error 1&lt;/li&gt; &lt;li&gt;Error 2&lt;/li&gt; &lt;li&gt;Error 3&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I tried with this too:</p> <pre><code>@Html.ValidationSummary(true, "Errors:", new { @class = "alert alert-error" }) </code></pre> <p>and it works ok, but without the close button (X)</p> <p>It generates HTML code like this:</p> <pre><code>&lt;div class="validation-summary-errors alert alert-error"&gt; &lt;span&gt;Errors:&lt;/span&gt; &lt;ul&gt; &lt;li&gt;Error 1&lt;/li&gt; &lt;li&gt;Error 2&lt;/li&gt; &lt;li&gt;Error 3&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>but Bootstrap alert should have this button into the div:</p> <pre><code>&lt;button type="button" class="close" data-dismiss="alert"&gt;×&lt;/button&gt; </code></pre> <p>Can anyone help?</p> <hr> <p><em><strong>This Works! - Thanks Rick B</em></strong></p> <pre><code>@if (ViewData.ModelState[""] != null &amp;&amp; ViewData.ModelState[""].Errors.Count() &gt; 0) { &lt;div class="alert alert-error"&gt; &lt;a class="close" data-dismiss="alert"&gt;×&lt;/a&gt; &lt;h5 class="alert-heading"&gt;Ingreso Incorrecto&lt;/h5&gt; @Html.ValidationSummary(true) &lt;/div&gt; } </code></pre> <p>I also had to remove the class ".validation-summary-errors" from "site.css", because that style defines other font color and weight.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload