📄 regularexpressionvalidator.cs
字号:
using System;
using System.Text.RegularExpressions;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for RegularExpressionValidator.
/// </summary>
public class RegularExpressionValidator : BaseValidator
{
public RegularExpressionValidator() : base()
{
}
protected virtual void AddAttributesToRender(HtmlTextWriter writer)
{
this.AddAttributesToRender(writer);
if (this.RenderUplevel)
{
writer.AddAttribute("evaluationfunction", "RegularExpressionValidatorEvaluateIsValid");
if (this.ValidationExpression.Length > 0)
writer.AddAttribute("validationexpression", this.ValidationExpression);
}
}
protected override bool EvaluateIsValid()
{
string local0;
Match local1;
bool local2;
local0 = this.GetControlValidationValue(this.ControlToValidate);
if (local0 == null || local0.Trim().Length == 0)
return true;
try
{
local1 = System.Text.RegularExpressions.Regex.Match(local0, this.ValidationExpression);
if (local1.Success && local1.Index == 0)
{
// goto i-1;
}
local2 = false;
}
catch
{
local2 = true;
}
return local2;
}
public string ValidationExpression
{
get
{
object local0;
local0 = this.ViewState["ValidationExpression"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
try
{
System.Text.RegularExpressions.Regex.IsMatch("", value);
}
catch (Exception local0)
{
throw new HttpException(System.Web.HttpRuntime.FormatResourceString("Validator_bad_regex", value), local0);
}
this.ViewState["ValidationExpression"]= value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -