Re: How to put errors in the Validation Summary

  •  10-20-2010, 10:32 PM

    Re: How to put errors in the Validation Summary

    Hi microcontroleur,
     
    Please try the example below. I integrated the error message into the Validation Summary control.
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4. <html xmlns="http://www.w3.org/1999/xhtml">  
    5. <head runat="server">  
    6.     <title>Untitled Page</title>  
    7. </head>  
    8. <body>  
    9.     <form id="form1" runat="server">  
    10.         <table border="1">  
    11.             <tr>  
    12.                 <td>  
    13.                     Name:  
    14.                     <asp:TextBox ID="textBox1" runat="server"></asp:TextBox>  
    15.                 </td>  
    16.                 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="textBox1"  
    17.                     runat="server" ErrorMessage="please type your name"></asp:RequiredFieldValidator>  
    18.             </tr>  
    19.             <tr>  
    20.                 <td>  
    21.                     <CuteWebUI:UploadAttachments ID="UploadAttachments1" runat="server">  
    22.                         <ValidateOption MaxSizeKB="1" />  
    23.                     </CuteWebUI:UploadAttachments>  
    24.                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="textBox2"  
    25.                         runat="server" ErrorMessage="the file is too large!"></asp:RequiredFieldValidator>  
    26.                 </td>  
    27.             </tr>  
    28.         </table>  
    29.         <br />  
    30.         <asp:Button ID="button1" runat="server" Text="Submit(start verification)" />  
    31.         <asp:ValidationSummary ID="ValidationSummary1" runat="server" />  
    32.         <asp:TextBox ID="textBox2" runat="server" Text="textBox2" Style="visibility: hidden"></asp:TextBox>  
    33.     </form>  
    34. </body>  
    35. </html>  
    36.   
    37. <script>  
    38.    function CuteWebUI_AjaxUploader_OnError(msg)  
    39.   
    40.     {  
    41.         if(msg.indexOf("is too large")!=-1)  
    42.   
    43.         {  
    44.             var textBox2=document.getElementById("<%= textBox2.ClientID %>");  
    45.             textBox2.value="";  
    46.                    return false;  
    47.         }  
    48.   
    49.     }  
    50. </script> 

     Regards,
     
    ken
View Complete Thread