ASP.NET MVC 2 client side validation not working for Html.ValidationMessage()?

Posted by JuniorDeveloper on Stack Overflow See other posts from Stack Overflow or by JuniorDeveloper
Published on 2010-04-11T12:50:45Z Indexed on 2010/04/11 12:53 UTC
Read the original article Hit count: 315

I'm trying to get a very simple client side validation example to work in ASP.NET MVC 2. I'm using data annotations to set a required property "Surname". When I use the Html.ValidationMessageFor(x => x.Surname) the correct client side validation script is written to the page. But when I use Html.ValidationMessage("Surname") the client side validation is not rendered out until after the page has been posted. Client side validation only starts working after a form post! I can see that the script is updated in the page after a form post. There appears to be a bug in Html.ValidationMessage()?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc