2014-03-06 61 views

回答

0

在模型中只需添加数据注释:

[Required(ErrorMessage = "You must select a RentInfo")] 
    public int CdcPortalRentInfoId{ get; set; } 
    public int Description{ get; set; } //I think this is you property 
+0

不过我它不是为我工作。 –

0

尝试这样的事情有要求的属性在MVC

public class CdcPortalRentInfo 
{ 
     [Required(ErrorMessage="Your Error Message")] 
     public int CdcPortalRentInfoId{ get; set; } 

     public string Description {get;set;} 
} 
+0

不过,我没有为我工作。 –

+0

你正在得到什么错误? –

+0

请参阅http://stackoverflow.com/questions/8345763/required-validation-attribte-not-working-in-asp-net-mvc-3-while-others-work –

相关问题