Can anyone give me a nice link to Implement ASP.NET MVC2 validation for my dropdownlist in my view?
My Dropdownlist in my view is something like this:
<%: Html.DropDownListFor(model => model.SelectedStudent,
new SelectList(Model.StudentIDs, "ID", "Name"),
"Please select..",
new { id="Student", style = "width:190px;" })%>
and my validation message is:
<%:Html.ValidationMessageFor(model => model.SelectedStudent) %>
in my Model I have this validation:
[DisplayName("Student")]
[Required(ErrorMessage="Please Select StudentID.")]
public int Student{ get; set; }
But somehow it's not validating and I am not seeing validation message in my view.
Something causing problem with "Please select"? or please correct me if I am wrong..
Thanks