asp.net - 样式化 ASP.NET MVC 验证错误不起作用?
问题描述
我已经设置了 .field-validation-error 的样式,如图所示
.field-validation-error{ color: red; font-weight: bold; }
还有 .input-validation-error
.input-validation-error{ border: 2px solid red; }
但不幸的是,我的验证错误和输入字段与以前的颜色相同。
这是html代码
@model MovieApp.ViewModel.CustomerFormViewModel
@{
ViewBag.Title = "New";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<br />
<h1>New customer</h1>
@using (Html.BeginForm("Save", "Customers"))
{
<div class="form-group">
@Html.LabelFor(c => c.Customer.FirstName)
@Html.TextBoxFor(c => c.Customer.FirstName, new { @class = "form-control" })
@Html.ValidationMessageFor(c => c.Customer.FirstName)
</div>
<div class="form-group">
@Html.LabelFor(c => c.Customer.LastName)
@Html.TextBoxFor(c => c.Customer.LastName, new { @class = "form-control" })
@Html.ValidationMessageFor(c => c.Customer.LastName)
</div>
<div class="form-group">
@Html.LabelFor(c => c.Customer.BirthDate)
@Html.TextBoxFor(c => c.Customer.BirthDate, new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(c => c.Customer.MembershipTypeId)
@Html.DropDownListFor(c => c.Customer.MembershipTypeId
,new SelectList(Model.MembershipTypes,"Id","Name")
,"Select Membership Type"
,new { @class = "form-control" })
@Html.ValidationMessageFor(c => c.Customer.MembershipTypeId)
</div>
<div class="checkbox">
<label>
@Html.CheckBoxFor(c => c.Customer.IsSubscribedToNewsLetter) Subscribed to newsletter?
</label>
</div>
@Html.HiddenFor(c => c.Customer.Id)
<button type="submit" class="btn btn-primary">SAVE</button>
}
解决方案
推荐阅读
- python - Python WX.MediaCtrl 黑色视频之间的过渡
- python-3.x - 我该如何解决这个问题。我正在尝试允许用户输入来解决将权重 xa 变化变量相乘的问题
- python - 球在 pygame 窗口的边缘反弹,需要一段时间才能出来
- openlayers - 使用 Geoserver 和 Openlayers 6 显示 WFS 图层
- node.js - 在本地部署和提供 React 应用程序构建后,服务器端无法工作
- python - 上传视频和缩略图 - YouTube Data API Python
- r - 使用 Rselenium 从下拉菜单中获取值
- flutter - 在颤动中访问提供程序设置器时不存在获取函数返回错误
- html - 在 iframe 中隐藏垂直滚动
- amazon-sqs - 带有 stepfunction 的 FIFO 主题需要 MessageGroupId 参数