File Size limit popup error message

Thread is closed for posting
2 posts, 0 answers
  1. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 20 Apr 2010 Link to this post

    The File Explorer control displays an error message if the file is larger than what is set for the control (Assuming that the setting in the web.config is not exceeded.).

    I set the control to 3mb, and the web.config to 10mb.

    Is it possible to display the same message for the readupload control?


    This control resides as an edit item template within a grid which is located in a user control

                                                                        <telerik:GridTemplateColumn UniqueName="Upload" HeaderText="File Name">  
                                                                            <ItemTemplate> 
                                                                                <asp:HyperLink ID="hlFile" runat="server" Target="_blank" /> 
                                                                            </ItemTemplate> 
                                                                            <EditItemTemplate> 
                                                                                <table cellpadding="0" cellspacing="0" border="0">  
                                                                                    <tr valign="top">  
                                                                                        <td> 
                                                                                            <asp:Label ID="lblValidFileTypesMessage" runat="server" Font-Size="X-Small" /> 
                                                                                        </td> 
                                                                                    </tr> 
                                                                                    <tr valign="top">  
                                                                                        <td style="height:40px;">  
                                                                                            <telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="1" InitialFileInputsCount="1" 
                                                                                                ControlObjectsVisibility="None" OverwriteExistingFiles="true" /> 
                                                                                        </td> 
                                                                                    </tr> 
                                                                                </table> 
                                                                            </EditItemTemplate> 
                                                                        </telerik:GridTemplateColumn> 
     
  2. Atlas
    Atlas avatar
    97 posts
    Member since:
    Jun 2009

    Posted 21 Apr 2010 Link to this post

    if (RadUpload1.InvalidFiles.Count > 0)  
    {  
        int iMaxFileSize = Convert.ToInt32(ConfigurationManager.AppSettings["FileSizeLimit"]);  
        if (RadUpload1.InvalidFiles[0].ContentLength > iMaxFileSize)  
        {  
            string sFileNameForJavascript = RadUpload1.InvalidFiles[0].FileName;  
            ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "alert('" + sFileNameForJavascript.Replace(@"\", @"\\") + ": The size of the uploaded file exceeds the max size allowed');", true);  
            return;  
        }  
    }  
     
    This works, and replicates the message sent by the file explorer.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top