⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 validationsummary.aspx

📁 亲密接触ASP.Net
💻 ASPX
字号:
<% @ Page Language="C#" %>
<Script Language="C#" Runat="Server">
public void Page_Load(Object src,EventArgs e)
{
	show.Text = "";
}
public void Button_Click(Object sender,EventArgs e)
{
	if(Page.IsValid)
	{
		show.Text = "验证通过";
	}
	else
	{
		show.Text = "验证失败";
	}
}
</script>
<html>
<head>
<title></title>
<style>
td{font-size:9pt}
</style>
</head>
<body>
<form runat="server">
<center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%">
    <tr>
      <td width="67%" colspan="3" bgcolor="#aaaadd" align="center"><b>
      <font color="#FFFF00">ValidationSummary演示</font></b></td>
    </tr>
    <tr>
      <td width="29%">姓名:</td>
      <td width="38%">
		<asp:TextBox id="Name" runat="server" />*
		<asp:RequiredFieldValidator id="chkName" runat="server"
			ControlToValidate="Name"
			Display="Static"
			ErrorMessage="请输入姓名"
		>
			<br>(必须填写)
		</asp:RequiredFieldValidator>
	  
	  </td>
      <td width="124%" rowspan="7" valign="top">
	  <asp:ValidationSummary id="chkall" runat="server"
		   DisplayMode="BulletList"
		   HeaderText="出现下列错误:"
	  />
	  </td>
    </tr>
    <tr>
      <td width="29%" bgcolor="#eeeeee">年龄:</td>
      <td width="38%" bgcolor="#eeeeee">
		<asp:TextBox id="Age" runat="server" />*
		<asp:RequiredFieldValidator id="chkAge1" runat="server"
			ControlToValidate="Age"
			Display="Static"
			ErrorMessage="请输入年龄"
		>
			<br>(必须填写)
		</asp:RequiredFieldValidator>
		<asp:CompareValidator id="chkAge2" runat="server"
			 ControlToValidate="Age"
			 Operator="DataTypeCheck"
			 Type="Integer"
			 ErrorMessage="年龄为数字"
		>
			<br>(请填写数字)
		</asp:CompareValidator>
	  </td>
    </tr>
    <tr>
      <td width="29%">性别:</td>
      <td width="38%">
		<asp:RadioButtonList id="Sex" RepeatDirection="Horizontal" runat="server">
			<asp:ListItem selected="True">男</asp:ListItem>
			<asp:ListItem>女</asp:ListItem>
		</asp:RadioButtonList>
	 </td>
    </tr>
    <tr>
      <td width="29%" bgcolor="#eeeeee">网站:</td>
      <td width="38%" bgcolor="#eeeeee">
		<asp:TextBox id="HomePage" runat="server" />*
		<asp:RegularExpressionValidator id="chkHomePage" runat="server"
			ControlToValidate="HomePage"
			ValidationExpression="^(http|HTTP).{1,}(com|net|cn|org)$"
			ErrorMessage="请输入合法的URL"
			Display="Static"
		>
			<br>(URL不合法)
		</asp:RegularExpressionValidator>	
	 </td>
    </tr>
    <tr>
      <td width="29%">Email:</td>
      <td width="38%">
		<asp:TextBox id="Email" runat="server" />*
		<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server"
            ControlToValidate="Email"
            ValidationExpression="^[a-zA-Z0-9]{1,}@[a-zA-Z0-9]{1,}\.(com|net|org|edu|mil|cn|cc)$"
			ErrorMessage="Email不合法"
            Display="Static"
		>
            <br>(Email不合法)
		</asp:RegularExpressionValidator>
	 </td>
    </tr>
    <tr>
      <td width="29%" bgcolor="#eeeeee">身份证号:</td>
      <td width="38%" bgcolor="#eeeeee">
		<asp:TextBox id="IdCard" runat="server" />*
		<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server"
			ControlToValidate="IdCard"
			ErrorMessage="请输入正确的身份证号"
			ValidationExpression="[0-9]{16,18}"
		>
			<br>(身份证号不合法)
		</asp:RegularExpressionValidator>

	  </td>
    </tr>
    <tr>
      <td width="29%"><asp:Button id="submit" Text="验证" OnClick="Button_Click" runat="server" /> </td>
      <td width="38%"><input type="reset" value="重来"></td>
    </tr>
  </table>
  </center>
<hr>
<asp:Label id="show" runat="server" />
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -