我有这个 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>
像这样它起作用了....为什么会这样?任何帮助,将不胜感激