Manually invoking ModelState validation

后端 未结 4 1505
心在旅途
心在旅途 2020-12-05 22:18

I\'m using ASP.NET MVC 3 code-first and I have added validation data annotations to my models. Here\'s an example model:

public class Product
{
    public i         


        
4条回答
  •  一整个雨季
    2020-12-05 23:17

    I found this to work and do precisely as expected.. showing the ValidationSummary for a freshly retrieved object on a GET action method... prior to any POST

    Me.TryValidateModel(MyCompany.OrderModel)
    

提交回复
热议问题