?? validationsummary.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="出現(xiàn)下列錯誤:"
/>
</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="年齡為數(shù)字"
>
<br>(請?zhí)顚憯?shù)字)
</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">網(wǎng)站:</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>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -