using IDataErrorInfo in asp.net mvc

后端 未结 3 1609
无人及你
无人及你 2020-12-16 07:09

I\'ve got a simple address entry app that I\'m trying to use the IDataErrorInfo interface as explained on the asp.net site.

It works great for items that can be val

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 07:54

    For more complex business rule validation, rather than type validation it is maybe better to implement design patterns such as a service layer. You can check the ModelState and add errors based on your logic.

    You can view Rob Conroys example of patterns here

    http://www.asp.net/learn/mvc/tutorial-29-cs.aspx

    This article on Data Annotations ay also be useful.

    http://www.asp.net/learn/mvc/tutorial-39-cs.aspx

    Hope this helps.

提交回复
热议问题