2014-03-06 62 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 –

相關問題