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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -