我正在学习MVC,而在ASP.Net MVC 3中,什么是
ModelState类?我看过Google和MSDN,但我似乎无法清楚地了解它的目的.谁能帮忙?
解决方法
看看
http://www.gxclarke.org/2010/05/consumption-of-data-in-mvc2-views.html在ViewData.ModelState部分.
The ModelState property is a dictionary object that tracks HTTP values submitted to the server. In addition to storing the name and value of each field,it also tracks associated validation errors. Although its name may suggest otherwise,ModelState isn’t Model-aware. It doesn’t understand what a “Product” is. It simply contains a collection of items with names such as “ProductName” and “UnitPrice”. It is the responsibility of other objects—ModelBinders,ViewResult,and the strongly-typed View—to map and interpret ModelState values as Model properties