问题描述
我是工作在今天MVC1应用程序迁移到MVC2,我已经遇到一个问题,同时改变ValidationMessage到ValidationMessageFor执行。
I was working on migrating MVC1 app to MVC2 today and i have come across a problem while changing the ValidationMessage to ValidationMessageFor implementation.
下面是选择列表在我看来
The below is the selectlist in my View
<%=Html.DropDownListFor(model => model.SecurityQuestions[0].Question, "Some Security question", new { @class = "form_element_select" })%>
下面code工作正常,我可以看到的ModelState验证消息就来了。
The below code works fine and i can see the validation message came from modelstate.
<%= Html.ValidationMessage("SecurityQuestions_0__Question")%>
但这个不起作用:
but this one does not work:
<%= Html.ValidationMessageFor(model => model.SecurityQuestions[0].Question)%>
SecurityQuestions是在我的模型泛型列表
SecurityQuestions is a generic list in my model
public List<SecurityQuestion> SecurityQuestions { get; set; }
这是多少有些ValidationMessageFor还是我失去了一些东西在这里?一个bug
Is this somewhat a bug in "ValidationMessageFor" or am i missing something here?
我有previously问。
I have previously asked this question on asp.net forums.
推荐答案
此问题在MVC V3
This problem is fixed in MVC V3
这篇关于实施ValidationMessageFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!