Skip to main content
A newer version of this page is available. .
Tab

UploadControlValidationSettings.MaxFileSize Property

Gets or sets the maximum file size (in bytes).

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

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

Property Value

Type Default Description
Int64 0

An Int64 value which specifies the maximum file size.

Property Paths

You can access this nested property as listed below:

Show 32 property paths
Library Object Type Path to MaxFileSize
ASP.NET Bootstrap Controls BootstrapBinaryImageUploadSettings
BootstrapUploadControl
.ValidationSettings.MaxFileSize
ASP.NET Web Forms Controls ASPxHtmlEditorAudioUploadSettings
.ValidationSettings.MaxFileSize
ASPxHtmlEditorFlashUploadSettings
.ValidationSettings.MaxFileSize
ASPxHtmlEditorImageUploadSettings
.ValidationSettings.MaxFileSize
ASPxHtmlEditorUploadControl
.ValidationSettings.MaxFileSize
ASPxHtmlEditorVideoUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorAudioSelectorUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorDocumentSelectorUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorFileManagerUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorFlashSelectorUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorImageSelectorUploadSettings
.ValidationSettings.MaxFileSize
HtmlEditorVideoSelectorUploadSettings
.ValidationSettings.MaxFileSize
RichEditDocumentSelectorUploadSettings
.ValidationSettings.MaxFileSize
SpreadsheetFileManagerUploadSettings
.ValidationSettings.MaxFileSize
ASPxUploadControl
.ValidationSettings.MaxFileSize
BinaryImageUploadSettings
FileManagerSettingsUpload
.ValidationSettings.MaxFileSize
UploadControlBinderSettings
.ValidationSettings.MaxFileSize
MVCxFileManagerSettingsUpload
.ValidationSettings.MaxFileSize
MVCxHtmlEditorAudioSelectorUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorAudioUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorDocumentSelectorUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorFileManagerUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorFlashSelectorUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorFlashUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorImageSelectorUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorImageUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorVideoSelectorUploadSettings
.ValidationSettings.MaxFileSize
MVCxHtmlEditorVideoUploadSettings
.ValidationSettings.MaxFileSize
MVCxUploadControl
.ValidationSettings.MaxFileSize
UploadControlSettings
.ValidationSettings.MaxFileSize

Remarks

If the uploaded file exceeds the MaxFileSize property’s value, an error text specified by the UploadControlValidationSettings.MaxFileSizeErrorText property is displayed within the ASPxUploadControl‘s specific error frame. The uploaded file’s validation is considered to have failed in this case (this means that the ASPxUploadControl.IsValid, FileUploadCompleteEventArgs.IsValid and ASPxClientUploadControlFileUploadCompleteEventArgs.isValid properties are set to false).

Example

The following sample code demonstrates how to save the file specified within the ASPxUploadControl on the client. Before file saving, the FileUploadCompleteEventArgs.IsValid property is tested to verify whether the file passes the validation criteria defined via the ASPxUploadControl.ValidationSettings property. Note, that in order to compose the ASPxUploadControl.SaveAs method’s parameter value, the System.Web.Hosting.HostingEnvironment.MapPath method and ASPxUploadControl.FileName property are used to specify the web application’s Image folder as a location where the file should be saved, and define the file’s name, respectively.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.1.0, Culture=neutral, 
PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxUploadControl" TagPrefix="dxuc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e){
    }
protected void ASPxUploadControl1_FileUploadComplete(object sender, 
DevExpress.Web.FileUploadCompleteEventArgs e) {
        if (e.IsValid) {
            ASPxUploadControl1.SaveAs(MapPath("Images/" + ASPxUploadControl1.FileName));
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>How to use the ASPxUploadControl's Validation Settings</title>
</head>
<body>
    <form id="form2" runat="server">
        <dxuc:ASPxUploadControl 
            ID="ASPxUploadControl1" 
            runat="server" 
            OnFileUploadComplete="ASPxUploadControl1_FileUploadComplete">
            <ValidationSettings 
                AllowedFileExtensions=".txt,.jpg,.jpe,.jpeg,.doc" 
                MaxFileSize="1000000" 
                FileDoesNotExistErrorText="This file can't be found." 
                GeneralErrorText="Custom file uploading fails due to an external error that 
                    doesn't relate to the ASPxUploadControl's functionality" 
                MaxFileSizeErrorText="Size of the uploaded file exceeds maximum file size" 
                NotAllowedContentTypeErrorText="The uploaded file's content type isn't allowed">
                <ErrorStyle BackColor="Yellow" ForeColor="Black" />
            </ValidationSettings>
        </dxuc:ASPxUploadControl>

    </form>
</body>
</html>
See Also