DisplayFor ignores metadata

Posted by Juvaly on Stack Overflow See other posts from Stack Overflow or by Juvaly
Published on 2010-03-01T16:54:49Z Indexed on 2010/04/03 6:53 UTC
Read the original article Hit count: 153

For my Contact class, the property EmailAddress is marked with the [DataType(DataType.EmailAddress)] attribute.

In my view, using Html.Display("EmailAddress") and Html.DisplayFor(c => c.EmailAddress) yields different results. The former outputs a mailto: link, which is the expected behavior, while the latter simply outputs the email address as plain text.

My question is why the different behavior, I expected these two methods to have the same output.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-2