Posts

Showing posts with the label html-helper

@Html.ValidationMessageFor() required field displaying message when populated

Image
Clash Royale CLAN TAG #URR8PPP @Html.ValidationMessageFor() required field displaying message when populated I am currently using ASP.net MVC (VB). I have a model with the following property: <Required(ErrorMessage:="Contact name is required")> Public Property contact_name() As String <Required(ErrorMessage:="Contact name is required")> Public Property contact_name() As String In my controller method (accepts a post request and binds various parameters to the model) I set contact_name from two other parameters : model.contact_name = first_name + " " + last_name model.contact_name = first_name + " " + last_name I return to my view containing a form which has an input field with a value of model.contact_name and I use the tag model.contact_name @Html.ValidationMessageFor(Function(model) model.contact_name @Html.ValidationMessageFor(Function(model) model.contact_name The problem is that the error message is always displayed, unles...