ASP.NET中 ValidationSummary(驗證總結)的使用


ylbtech-ASP.NET-Control-Validator: ValidationSummary(驗證總結)的使用

 ASP.NET中 ValidationSummary(驗證總結)的使用。

1.A,運行效果返回頂部

ValidationSummary(驗證總結)


屬性:
DisplayMode:顯示模式
    List:類表     BulletList:無序列表     SingleParagraph:單行段落      

用戶名:  
  密碼:   
郵箱地址:   

 
請輸入用戶名 請輸入密碼 
   
1.B,源代碼返回頂部
/Demo6.aspx
View Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Demo6.aspx.cs" Inherits="Demo6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>無標題頁</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h2>ValidationSummary(驗證總結)</h2>
    <hr />
    屬性:<br />    
    DisplayMode:顯示模式
    <pre>
    List:類表
   BulletList:無序列表
   SingleParagraph:單行段落
    </pre>
    <hr />
   用戶名:<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="txtUsername" Display="None" ErrorMessage="請輸入用戶名"></asp:RequiredFieldValidator>
        <br />
&nbsp;密碼:
    
        <asp:TextBox ID="txtUserpass" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
            ControlToValidate="txtUserpass" Display="None" ErrorMessage="請輸入密碼"></asp:RequiredFieldValidator>
        <br />
                郵箱地址: 
        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="txtEmail" Display="None" ErrorMessage="郵箱格式有誤" 
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="提交" />
        <br />
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
            DisplayMode="SingleParagraph" BackColor="Yellow" />
    </div>
    </form>
</body>
</html>
1.C,資源下載返回頂部

http://files.cnblogs.com/ylbtech/WebForm-BasicControl-Validator.rar

warn 作者:ylbtech
出處:http://ylbtech.cnblogs.com/
本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM