asp.net MVC3验证默认颜色显示为黑色而不是红色

时间:2012-09-04 07:23:50

标签: asp.net-mvc asp.net-mvc-3

我正在使用MVC3。我有一个基本的项目工作正常,并将默认的MVC验证显示为红色。

现在验证虽然仍然有效,却显示为黑色而不是红色。除此之外,一切都很好。

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")

    @using (Html.BeginForm("Logon", "Research", 
            new { returnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post, 
            new { @class = "form"}))
    {


                <div style="margin-top:20px">
                  @Html.LabelFor(m => m.UserName)
                  <div class="input">
                    @Html.TextBoxFor(m => m.UserName)                
                  </div>
                  <div class="input">
                    @Html.ValidationMessageFor(m => m.UserName)
                  </div>              
                </div>

                <div>
                  @Html.LabelFor(m => m.Password)
                  <div class="input">
                    @Html.PasswordFor(m => m.Password)                
                  </div>
                  <div class="input">
                    @Html.ValidationMessageFor(m => m.Password)
                  </div>
                </div>

                <div class="actions" style="margin-bottom:20px">              
                  <input type="submit" value="Log On" class="button" />
                </div>

    }

2 个答案:

答案 0 :(得分:2)

在默认站点css文件中更改以下类:

.field-validation-error
{
    color: Black;
}

.validation-summary-errors
{
    font-weight: bold;
    color: Black;
}

答案 1 :(得分:-1)

在您的布局中加入~/Content/css