[我的ASP.net学习历程]RegularExpressionValidator

类别:Asp 点击:0 评论:0 推荐:

<%@ Page Language="C#" AutoEventWireup="True" %>
<Script language="C#" runat="server">
void Page_Load(Object Sender,EventArgs e){

}
void ButtonClick(Object Sender,EventArgs E){
 if (Page.IsValid){
  Label_1.Text=TextBox_1.Text;
  }
 else{
  Label_1.Text="Error input!";
  }
}
</Script>
<form id="Form_1" runat="server">
 <asp:textbox ID="TextBox_1" runat="server"/>
 <asp:RegularExpressionValidator id="RegularExpressionValidator1"
                     ControlToValidate="TextBox_1"
                     ValidationExpression=".*@.*\..*"
                     Display="Static"
                     EnableClientScript="false"
                     ErrorMessage="Error E-mail!"
                     runat="server"/>
 <asp:button ID="Button_1" Text="Button" OnClick="ButtonClick" runat="server"/>
</form>
<asp:label ID="Label_1" runat="server"></asp:label>

本文地址:http://com.8s8s.com/it/it8565.htm