Set required to select validation for dropdown list in asp.net razor -
how can apply selection required validation on dropdownlist in asp.net razor without using model. below dropdownlist
<td>@html.dropdownlist("units", new selectlist(@viewbag.settings.cdcportalrentinfo , "cdcportalrentinfoid" , "description") , new { style = "width:250px" }) </td>
try required attribute in mvc
public class cdcportalrentinfo { [required(errormessage="your error message")] public int cdcportalrentinfoid{ get; set; } public string description {get;set;} }
Comments
Post a Comment