Reputation: 411
I couldn't get this code working. It's not displaying validation error message when I submit the form.
viewModel
[Required]
public SelectList CountryList { get; set; }
public string Country { get; set; }
Create.aspx
<%= Html.DropDownListFor(m => m.Country,Model.CountryList, "--Select--")%>
<%: Html.ValidationMessageFor(model => model.Country,"*") %>
Upvotes: 1
Views: 749
Reputation: 8199
Try this
public SelectList CountryList { get; set; }
[Required]
public string Country { get; set; }
Upvotes: 2