更新时间:2022-11-10 19:31:05
如果你使用JQuery Ajax,你的问题的解决方案将变得容易
How to fetch dropdown selected value from view in controller to add ModelState error as we added for textbox values for being null?
if (string.IsNullOrEmpty(employee.Name))
{
ModelState.AddModelError("Name","The Name field is required");
}
Ex:When we are creating an Employee if the user selects "Select Department" value from Department dropdown list,we need to add the error stating "Please select the valid Department"
How do we achieve this?
The solution to your problem will become easy if you make use of JQuery Ajax