ASP.NET MVC - ValidationMessageFor
Posted
by Murat
on Stack Overflow
See other posts from Stack Overflow
or by Murat
Published on 2010-04-21T07:54:32Z
Indexed on
2010/04/21
11:23 UTC
Read the original article
Hit count: 997
asp.net-mvc-2
|validation
Hi, I have asked this question on asp.net forums (http://forums.asp.net/t/1545006.aspx) but i had no valid answer therefore i'll try this here as well.
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" })%>
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 is a generic list in my model
public List<SecurityQuestion> SecurityQuestions { get; set; }
Is this somewhat a bug in "ValidationMessageFor" or am i missing something here?
© Stack Overflow or respective owner