Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml.TextBox with css class specified conflicts with form validation css (input-validation-error)
    primarykey
    data
    text
    <p>Interesting situation. I have a Html.Textbox() that I render from a view as follows:</p> <pre><code>&lt;%= Html.TextBox("title", Model.Title, new { @class = "txt" }) %&gt; </code></pre> <p>In my controller, I have the following, somewhat simplified, validation on the title. For arguments sake, assume it finds the error, and re-renders the view with the modelstate error information.</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult EditBook(string title) { Model = new Book(ControllerContext.RequestContext); if (String.IsNullOrEmpty(title)) { title = String.Empty; ModelState.AddModelError("title", "* Title is a required"); modelState.SetModelValue("title", ValueProvider["title"]); } else { // show confirmation } if (!ModelState.IsValid) { return View("EditBook", Model); } } </code></pre> <p>When the page is re-rendered, my html text box correctly has the input-validation-error class attached to it... But it's useless as it's the first class attached! I need it to override all existing styles on my text box. The html output is as follows:</p> <pre><code>&lt;input type="text" name="title" id="title" class="input-validation-error txt"/&gt; </code></pre> <p>Assume the following css styles have been defined:</p> <pre><code>input.txt { border: 1px; color: #000 } .input-validation-error { border: 2px solid #fff } </code></pre> <p>The problem is, my original css class "txt" takes precedence, and prevents me from being able to style the error text box correctly. </p> <p>Any thoughts?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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