是否有可能在ASP.NET WEBFORM业务对象类使用数据注释的MVC? [英] Is it possible to use Data Annotations for MVC in an ASP.NET WEBFORM Business Object Class?
问题描述
我怎么能在一个asp.net WEBFORM业务对象类使用这种约定?
How can I use this convention in an asp.net WEBFORM Business object class?
例子在MVC
using System.ComponenModel.DataAnnotation;
public class Customer
{
[Required]
[StringLength(5,20)]
public string FirstName { get; set;}
[Required]
[StringLength(5,20)]
public string LastName { get; set;}
}
我想在我的asp.net BusinessObject的网页表单类使用此数据注解的客户端验证和服务器验证。
I want to use this data annotation in my asp.net webform businessobject class for client validation and server validation.
推荐答案
不幸的WebForms没有数据注释像MVC的原生支持。
Unfortunately WebForms doesn't have native support of Data Annotations like MVC.
但你可以使用自定义的决定:
But you can use custom decisions:
-
<一个href=\"http://www.i$p$pferjim.com/2010/05/system-componentmodel-dataannotations-for-asp-net-web-forms/\">system componentmodel dataannotations的asp.net web表单
<一个href=\"http://adventuresdotnet.blogspot.com/2009/08/aspnet-webforms-validation-with-data.html\">ASP.NET: WebForms的验证与数据注释
这篇关于是否有可能在ASP.NET WEBFORM业务对象类使用数据注释的MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!