Customize Validation Error Dialog

Last post 10-14-2011, 7:18 AM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  09-19-2010, 4:27 PM 64083

    Customize Validation Error Dialog

    Is it possible to change the JS alert message thrown when there is a validation error? I would like to use a cleaner more user friendly dialog like colorbox.
     
    I am using MVC 2.
     
    Thanks.

    Paul
    Post Hope
  •  09-19-2010, 6:48 PM 64087 in reply to 64083

    Re: Customize Validation Error Dialog

    You can try the following code:
     
      <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Upload"
                    OnFileUploaded="Uploader_FileUploaded" FileTooLargeMsg="You can customize this msg.{0} cannot be uploaded!
    File size ({1}) is too large. The maximum file size allowed is set to: {2}."
                    MaxFilesLimitMsg="Please customize msg {0}.">
                    <ValidateOption AllowedFileExtensions="jpeg,jpg,gif,png" MaxSizeKB="100" />
                </CuteWebUI:Uploader>
     
    Thank you for asking
  •  10-14-2011, 5:07 AM 70393 in reply to 64087

    Re: Customize Validation Error Dialog

    Hi,
     
    I want to set MaxFileSize from code behind.
    ValidateOption.MaxSizeKB = " 1024" 
    Than it is possible to customize the error dialog?
    thanks,
    Hemantp 
  •  10-14-2011, 7:18 AM 70395 in reply to 70393

    Re: Customize Validation Error Dialog

    Hi hemantp,
     
    Yes, you can use the same way to custom the file too large message.
     
    Try the example below
     
    <%@ Page Language="C#" %>

    <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            uploader1.ValidateOption.MaxSizeKB = 10;
            uploader1.FileTooLargeMsg = "file too large";
            base.OnLoad(e);
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <CuteWebUI:UploadAttachments ID="uploader1" runat="server">
            </CuteWebUI:UploadAttachments>
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken
View as RSS news feed in XML