0

我有这个 Ajax 表单

@using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST", OnSuccess = "SucessoCriarUsuario", OnFailure = "FalhaCriarUsuario" }))
{

    <div class="separador">
        <div class="linha1">
            @Html.LabelFor(m => m.Nome)
            <br />
            @Html.TextBoxFor(m => m.Nome)
            @Html.ValidationMessageFor(m => m.Nome)
        </div>
        <div class="linha1">
            @Html.LabelFor(m => m.Login)
            <br />
            @Html.TextBoxFor(m => m.Login)
            @Html.ValidationMessageFor(m => m.Login)
        </div>
        <div class="linha2">
            @Html.LabelFor(m => m.Email)
            <br />
            @Html.TextBoxFor(m => m.Email)
            @Html.ValidationMessageFor(m => m.Email)
        </div>
    </div>
    <br />
    <br />
    <div class="separador">
        <div class="linha2">
            @Html.LabelFor(m => m.Perfil)<br>
            @Html.DropDownListFor(m => m.Perfil, new SelectList(UsuarioController.ObterListaPerfis(User.Identity.Name)))
        </div>
        <div class="linha2">
            @Html.LabelFor(m => m.Ativacao)<br>
            @Html.DropDownListFor(m => m.Ativacao, new SelectList(new List<string> { "Ativo", "Inativo" }))
        </div>
        <div class="linha2">
            <br>
            <input type="submit" value="Salvar" />
            <input type="button" id="btnCancelar" value="Cancelar" />
        </div>
    </div>

}

而且我有validationmessagefor字段和textBoxFor字段的覆盖css......但是当我导入具有这些覆盖类的css文件时......

<head>
    <link href="@Url.Content("~/Content/ModalStyle.css")" rel="stylesheet" type="text/css" />
</head>

CSS不适用于validationmessageFor和textBoxFor ...它仅在我将css放在同一页面上时才有效

<head>
<style type="text/css">

.input-validation-error
{
    border: 1px solid red;
}


.field-validation-error
{
    color: red;
    font-weight: bold;
}

</style>
</head>

像这样它起作用了....为什么会这样?任何帮助,将不胜感激

4

1 回答 1

0

它可能被另一个 css 或 css 规则覆盖。将它(CSS 规则)更改为 css 文件中的以下内容,看看它是否修复了它:

.input-validation-error
{
    border: 1px solid red !important;
}


.field-validation-error
{
    color: red !important;
    font-weight: bold !important;
}
于 2013-08-08T18:12:46.640 回答