什么是MVC 3的ModelState类? [英] What is the ModelState class in MVC 3?

查看:177
本文介绍了什么是MVC 3的ModelState类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习MVC和在ASP.Net MVC 3,是什么<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.modelstate%28v=vs.98%29.aspx\">ModelState上课吗?我期待在谷歌和MSDN,但我似乎无法得到它的目的清醒的认识。谁能帮助?

I am learning MVC, and in ASP.Net MVC 3, what is the ModelState class ? I have looked on Google and MSDN, but I can't seem to get a clear understanding of it's purpose. Can anyone help?

推荐答案

在看看<一个href=\"http://www.gxclarke.org/2010/05/consumption-of-data-in-mvc2-views.html\">http://www.gxclarke.org/2010/05/consumption-of-data-in-mvc2-views.html在 ViewData.ModelState 部分。

该ModelState中属性是跟踪提交到服务器的HTTP值的字典对象。除了存储的名称和各自字段的值,它也跟踪关联的验证错误。虽然它的名字可能并非如此,ModelState中并不型号感知。它不明白什么是产品是什么。它只是包含的项目有名称,如产品名称和单价的集合。这是其他对象 - ModelBinders,的ViewResult和强类型的视图,映射和跨preT 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

这篇关于什么是MVC 3的ModelState类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆