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
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01