Skip to main content
Tab

UploadControlValidationSettings.MaxFileSize Property

Specifies the maximum size of the uploaded file.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

[DefaultValue(0L)]
public virtual long MaxFileSize { get; set; }

Property Value

Type Default Description
Int64 0

The maximum file size in bytes. 0, if the maximum size is not limited.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to MaxFileSize
ASP.NET MVC Extensions UploadControlBinderSettings
.ValidationSettings .MaxFileSize
UploadControlSettings
.ValidationSettings .MaxFileSize
ASP.NET Web Forms Controls ASPxUploadControl
.ValidationSettings .MaxFileSize

Remarks

Use the MaxFileSize property to limit the uploaded file size. If the uploaded file exceeds the property value, the ASPxUploadControl displays an error description. Use the MaxFileSizeErrorText property to customize the error text.

<dx:ASPxUploadControl ID="ASPxUploadControl1" runat="server" OnFileUploadComplete="uc_FileUploadComplete">
    <ValidationSettings AllowedFileExtensions=".txt,.jpg,.jpe,.jpeg,.doc" MaxFileSize="1000000" 
        FileDoesNotExistErrorText="A file cannot be found." 
        GeneralErrorText="File uploading fails due to an external error that doesn't relate to the ASPxUploadControl's functionality." 
        MaxFileSizeErrorText="Uploaded file size exceeds the maximum file size." 
        NotAllowedFileExtensionErrorText="The file extension is not allowed.">
        <ErrorStyle BackColor="Yellow" ForeColor="Black" />
    </ValidationSettings>
</dx:ASPxUploadControl>
protected void uc_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) {
    if (e.IsValid) {
        ASPxUploadControl1.SaveAs(MapPath("Images/" + ASPxUploadControl1.FileName));
    }
}

Exception

In the Standard Upload Mode, if the MaxFileSize property value exceeds the value of the Web.config’s MaxRequestLength setting, the following error occurs:

The ValidationSettings.MaxFileSize property’s value exceeds the Web.Config’s maxRequestLength setting. For the ASPxUploadControl’s built-in validation to work correctly, the ValidationSettings.MaxFileSize property should be less than the Web.config’s maxRequestLength setting.

To solve the issue, set the MaxFileSize value less than the MaxRequestLength value or use the Advanced Upload Mode.

See Also