码迷,mamicode.com
首页 > Web开发 > 详细

web form 服务器控件表单验证

时间:2017-03-08 13:44:35      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:erro   dem   doc   表单验证   register   asp   textbox   button   span   

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidationDemo.aspx.cs" Inherits="Validation.ValidationDemo" %>
 2 
 3 <!DOCTYPE html>
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7     <title></title>
 8 </head>
 9 <body>
10     <form id="form1" runat="server">
11     <div>
12       <table class="auto-style1">
13         <tr>
14           <td>Name:</td>
15           <td>
16             <asp:TextBox ID="TextName" runat="server"></asp:TextBox>
17             <asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
18               runat="server" ControlToValidate="TextName" 
19               ErrorMessage="Name required">*</asp:RequiredFieldValidator>
20           </td>
21         </tr>
22         <tr>
23           <td>Email:</td>
24           <td>
25             <asp:TextBox ID="TextEmail" runat="server"></asp:TextBox>
26             <asp:RequiredFieldValidator ID="RequiredFieldValidator2" 
27               runat="server" ControlToValidate="TextEmail" Display="Dynamic" 
28               ErrorMessage="Email required">*</asp:RequiredFieldValidator>
29             <asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
30               runat="server" ControlToValidate="TextEmail" Display="Dynamic" 
31               ErrorMessage="Please enter an email" 
32               ValidationExpression="\w+([-+.‘]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
33           </td>
34         </tr>
35         <tr>
36           <td>
37             <asp:Button ID="Button1" runat="server" Text="Register" />
38           </td>
39           <td>&nbsp;</td>
40         </tr>
41       </table>
42 
43     </div>
44         <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
45     </form>
46 </body>
47 </html>

 

web form 服务器控件表单验证

标签:erro   dem   doc   表单验证   register   asp   textbox   button   span   

原文地址:http://www.cnblogs.com/farmer-y/p/6518753.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!