Back to Devexpress

UploadControlValidationSettings.AllowedFileExtensions Property

aspnet-devexpress-dot-web-dot-uploadcontrolvalidationsettings-2d96a828.md

latest4.4 KB
Original Source

UploadControlValidationSettings.AllowedFileExtensions Property

Gets or sets the allowed file extensions of the uploaded file.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public virtual string[] AllowedFileExtensions { get; set; }
vb
Public Overridable Property AllowedFileExtensions As String()

Property Value

TypeDescription
String[]

An array of string values that contains the allowed file extensions.

|

Property Paths

You can access this nested property as listed below:

LibraryObject TypePath to AllowedFileExtensions
ASP.NET MVC ExtensionsUploadControlBinderSettings

.ValidationSettings .AllowedFileExtensions

| | UploadControlSettings |

.ValidationSettings .AllowedFileExtensions

| | ASP.NET Web Forms Controls | ASPxUploadControl |

.ValidationSettings .AllowedFileExtensions

|

Remarks

Use the AllowedFileExtensions property to specify which file extensions are allowed for uploading. If the uploaded file’s extension is not allowed (it’s not listed by the AllowedFileExtensions property), the ASPxUploadControl ‘s validation fails and the UploadControlValidationSettings.NotAllowedFileExtensionErrorText property’s value is displayed within the control’s specific error frame or alert box when the upload control operates in Standard or Advanced upload modes, respectively.

If the ASPxUploadControl validation fails, the FileUploadCompleteEventArgs.IsValid, UploadedFile.IsValid and ASPxClientUploadControlFileUploadCompleteEventArgs.isValid properties are set to false.

Note that the AllowedFileExtensions property is used only for validating the uploaded file extension. The AllowedFileExtensions property doesn’t allow you to customize the appearance of the File Extension filter in the Open File dialog window. The displayed list of file extensions within the File Extension filter depends on a browser and is controlled by it.

Members of an array provided by the AllowedFileExtensions property are standard file extensions which begin with a dot symbol (c# code) and are separated using commas (aspx code).

aspx
<dx:ASPxUploadControl runat="server">
    <ValidationSettings AllowedFileExtensions=".jpg,.jpeg,.gif,.png" />
</dx:ASPxUploadControl>
csharp
AllowedFileExtensions=new String[] { ".jpe", ".jpeg", ".jpg", ".gif", ".png" };

See Also

NotAllowedFileExtensionErrorText

ASPxUploadControl - Online Demos

UploadControlValidationSettings Class

UploadControlValidationSettings Members

DevExpress.Web Namespace