Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用asp控件在asp.net中进行验证_Asp.net_Validation - Fatal编程技术网

使用asp控件在asp.net中进行验证

使用asp控件在asp.net中进行验证,asp.net,validation,Asp.net,Validation,对于asp.net中表达式的验证,这意味着什么?我在网上找到这个来检查表达式 [RegularExpression("^[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*$")] 这是一个属性,由[…]表示。其中包含的RegularExpression用于将任何字符串与之进行比较,并接受或拒绝该字符串 从 范例 下面的示例演示如何使用RegularExpressionAttribute属性验证FirstName和LastName数据字段。正则表达式最多允许40个大小写字

对于asp.net中表达式的验证,这意味着什么?我在网上找到这个来检查表达式

[RegularExpression("^[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*$")]

这是一个
属性
,由
[…]
表示。其中包含的RegularExpression用于将任何字符串与之进行比较,并接受或拒绝该字符串

范例

下面的示例演示如何使用RegularExpressionAttribute属性验证FirstName和LastName数据字段。正则表达式最多允许40个大小写字符。该示例执行以下任务:
• 实现元数据分部类和关联的元数据类。 • 在关联的元数据类中,将RegularExpressionAttribute属性应用于FirstName和LastName数据字段,指定模式和自定义错误消息

   using System;
   using System.Web.DynamicData;
   using System.ComponentModel.DataAnnotations;


   [MetadataType(typeof(CustomerMetaData))]
   public partial class Customer
   {


   }

   public class CustomerMetaData
   {

       // Allow up to 40 uppercase and lowercase  
       // characters. Use custom error.
       [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", 
            ErrorMessage = "Characters are not allowed.")]
       public object FirstName;

       // Allow up to 40 uppercase and lowercase  
       // characters. Use standard error.
       [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")]
       public object LastName;
   }

Seema,为什么不做一些作业@

是一个非常有用的网站,关于Regex。不过,我原以为你会先对这样一个问题大发雷霆或用谷歌搜索。你到底想知道什么?
   using System;
   using System.Web.DynamicData;
   using System.ComponentModel.DataAnnotations;


   [MetadataType(typeof(CustomerMetaData))]
   public partial class Customer
   {


   }

   public class CustomerMetaData
   {

       // Allow up to 40 uppercase and lowercase  
       // characters. Use custom error.
       [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", 
            ErrorMessage = "Characters are not allowed.")]
       public object FirstName;

       // Allow up to 40 uppercase and lowercase  
       // characters. Use standard error.
       [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")]
       public object LastName;
   }