This is a migrated thread and some comments may be shown as answers.

File Size limit popup error message

1 Answer 225 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 20 Apr 2010, 10:43 PM
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> 
 

1 Answer, 1 is accepted

Sort by
0
Atlas
Top achievements
Rank 1
answered on 21 Apr 2010, 07:06 PM
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.
Tags
Upload (Obsolete)
Asked by
Atlas
Top achievements
Rank 1
Answers by
Atlas
Top achievements
Rank 1
Share this question
or