Server Side ValidateOptions

Last post 07-03-2010, 2:42 AM by cutechat. 2 replies.
Sort Posts: Previous Next
  •  06-27-2010, 3:59 PM 62017

    Server Side ValidateOptions

    Greetings, possible to change MaxSizeKB and AllowedFileExtensions in code?
     
    If I change this on Page_Load:
     uploadAttachments.ValidateOption.MaxSizeKB = 2048;
     
    While the default is set to:
     <VALIDATEOPTION MaxSizeKB="1024" />
     
    If the file size is about the default value, error saying file size is too big...
  •  06-28-2010, 12:54 AM 62029 in reply to 62017

    Re: Server Side ValidateOptions

    Hi atwoodkevin,
     
    Try the below example, it works fine for me.
     
    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 id="Head1" runat="server">   
    6.     <title>Untitled Page</title>   
    7. </head>   
    8.   
    9. <script runat="server">   
    10.     protected override void OnLoad(EventArgs e)   
    11.     {   
    12.         attachment1.ValidateOption.MaxSizeKB = 12040;   
    13.         base.OnLoad(e);   
    14.     }   
    15.   
    16. </script>   
    17.   
    18. <body>   
    19.     <form id="form1" runat="server">   
    20.         <CuteWebUI:UploadAttachments ID="attachment1" runat="server">   
    21.             <ValidateOption MaxSizeKB="1024" />   
    22.         </CuteWebUI:UploadAttachments>   
    23.     </form>   
    24. </body>   
    25. </html>  
    Regards,
     
    ken
  •  07-03-2010, 2:42 AM 62262 in reply to 62017

    Re: Server Side ValidateOptions

    Hi,
     
    Make sure you do not use the IsPostBack property in the OnLoad event
     
    Because ValidateOptions is a security member, uploader will not remember it after postback.
     
    You need always set the value .
     
    Regards,
    Terry
     
View as RSS news feed in XML