views:

27

answers:

1

I have view with the following which works:

<%= Html.TextBoxFor(m => m.FirstName, new { @class = "required_field_light" }) %>
<%= Html.ValidationMessageFor(m => m.FirstName) %>

However, if I change the ValidationMessageFor() to a ValidateFor() like this:

<%= Html.ValidateFor(m => m.FirstName) %>

I get this compile error:

"The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments"
"Argument '1': cannot convert from 'void' to 'char'"

I assume I am missing something somewhere but I cannot figure out what it is. Has anyone else encountered this problem and found a solution, or does somebody have an idea how to resolve this?

+4  A: 

Since ValidateFor() returns void, call it like so:

<% Html.ValidateFor(m => m.FirstName); %>

(Note no equal sign; addition of semicolon.)

Levi
Did the trick. Thanks.
Sailing Judo