嗨,大家好我已经看过谷歌,雅虎,找不到答案,为什么它是我的'@Html.ValidationMessageFor不起作用。'当我运行应用程序时,什么都不会发生,它允许输入所有内容。当我尝试编辑我的编辑视图中的项目时,它也会崩溃。我有以下内容:@ Html.ValidationMessageFor无法正常工作
<div class="editor-label">
@* @Html.LabelFor(model => model.Posted)*@
</div>
<div class="editor-field">
@Html.HiddenFor(model => model.Posted, Model.Posted = DateTime.Now)
@Html.ValidationMessageFor(model => model.sendinghome)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Cartypes)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Cartypes)
@Html.ValidationMessageFor(model => model.Cartypes)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.RegNum)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.RegNum)
@Html.ValidationMessageFor(model => model.RegNum)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Regprice)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Image)
@Html.ValidationMessageFor(model => model.Regprice)
</div>
您应该显示更多代码。您的模型如何定义?任何数据注释属性?控制器怎么样? – 2012-01-04 22:55:30
一切工作罚款你想看到什么?这是验证不起作用?控制器如何影响它?因为代码的运行和工作正常,只有当我编辑 – user1128756 2012-01-04 22:57:43
如果一切正常,这个问题有什么意义?没有看到要验证的内容,我无法回答你的问题。那么你的验证规则是如何定义的?控制器如何处理模型的有效性? – 2012-01-04 22:59:09