追求卓越

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Asp.NET 4.5的新特性之一是改进了模型绑定方式(Model Binding)。通过借鉴ObjectDataSource和Asp.NET MVC的概念,Asp.NET 4.5扩展了模型绑定的方式,使程序员可更加方便地使用Asp.NET Web Form控件编写以代码为中心的数据访问程序。

在按照例子编写代码时发现一个小问题,在页面后台代码编写数据过滤方法时,Control属性并不被认可,提示System.Web.UI.Control不是特性类。如图:

 

解决方法,在类前添加 using System.Web.ModelBinding;(http://msdn.microsoft.com/zh-cn/library/system.web.modelbinding.aspx) ,该命名空间里定义了ControlAttribute , CookieAttribute ,FormAttribute ,ProfileAttribute ,QueryStringAttribute ,SessionAttribute 等。

参考资料:

What's New in ASP.NET 4.5 and Visual Studio 2012 http://www.asp.net/vnext/overview/aspnet/whats-new

posted on 2013-04-14 10:34  Chen@Ethos  阅读(405)  评论(0编辑  收藏  举报