Is it possible to use Data Annotations for MVC in an ASP.NET WEBFORM Business Object Class?(是否可以在 ASP.NET WEBFORM 业务对象类中对 MVC 使用数据注释?)
问题描述
如何在 asp.net WEBFORM 业务对象类中使用此约定?
MVC 示例
使用 System.ComponenModel.DataAnnotation;公开课客户{[必需的][字符串长度(5,20)]公共字符串名字{获取;放;}[必需的][字符串长度(5,20)]公共字符串姓氏 { 获取;放;}}
我想在我的 asp.net webform 业务对象类中使用此数据注释进行客户端验证和服务器验证.
不幸的是,WebForms 没有像 MVC 这样的数据注释的本机支持.
但您可以使用自定义决策:
系统组件模型asp.net 网络表单的数据注释
使用数据注释构建 ASP.NET 验证器p>
ASP.NET: WebForms Validation with数据注释
How can I use this convention in an asp.net WEBFORM Business object class?
Example In 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;}
}
I want to use this data annotation in my asp.net webform businessobject class for client validation and server validation.
Unfortunately WebForms doesn't have native support of Data Annotations like MVC.
But you can use custom decisions:
system componentmodel dataannotations for asp.net webforms
Building an ASP.NET Validator Using Data Annotations
ASP.NET: WebForms Validation with Data Annotations
这篇关于是否可以在 ASP.NET WEBFORM 业务对象类中对 MVC 使用数据注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以在 ASP.NET WEBFORM 业务对象类中对 MVC 使用


- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01