Log In
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Collapse]File Management
   [Expand]Product Information
   [Expand]File Manager
   [Collapse]File Upload
     ASPxUploadControl Overview
    [Collapse]Concepts (ASPxUploadControl)
      Upload Modes
      Uploading Large Files
      Multi-File Selection
      Page Life Cycle During File Upload
      Drag and Drop
       Allowed File Extensions
       Allowed File Count and Size
      Appearance Customization
    [Expand]Visual Elements
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Allowed File Extensions

The ASPxUploadControl allows specifying the extensions of files end-users can upload to the server.

Related API

Member Description
UploadControlValidationSettings.AllowedFileExtensions Specifies the allowed file extensions (server side).
ASPxClientUploadControlValidationSettings.allowedFileExtensions Returns the allowed file extensions (client side).
UploadControlValidationSettings.NotAllowedFileExtensionErrorText Specifies the error text indicating that the specified file's extension is not allowed.
UploadedFile.IsValid Specifies whether the uploaded file passes validation.
ASPxClientUploadControl.ValidationErrorOccurred Enables you to specify whether the selected file(s) are valid and provide an error text.
ASPxUploadControl.FileUploadComplete Occurs when the file has been uploaded.
ASPxClientUploadControl.FileUploadComplete Occurs on the client after the file has been uploaded.
ASPxUploadControl.FilesUploadComplete Occurs after all the selected files have been uploaded to the server.
ASPxClientUploadControl.FilesUploadComplete Occurs on the client after all selected files has been uploaded.

The following code snippets illustrates how to define the UploadControlValidationSettings.AllowedFileExtensions property declaratively or programmatically.

  • Declarative approach.
  • Programmatically.

End-users can upload any files if the UploadControlValidationSettings.AllowedFileExtensions property is not specified (or not set to an empty string).

If the uploaded file's extension is not allowed (not listed in the UploadControlValidationSettings.AllowedFileExtensions property), the ASPxUploadControl's validation fails and the control displays the UploadControlValidationSettings.NotAllowedFileExtensionErrorText property's value within an error frame or alert box when the upload control operates in Standard or Advanced upload modes, respectively.

The FileUploadCompleteEventArgs.IsValid, ASPxUploadControl.IsValid and ASPxClientUploadControlFileUploadCompleteEventArgs.isValid properties are set to false if the ASPxUploadControl's validation fails.

You can implement custom validation logic using the following events:

The FileUploadCompleteEventArgs.IsValid and ASPxClientUploadControlFileUploadCompleteEventArgs.isValid properties specify whether the uploaded file passes the validation criteria. The FileUploadCompleteEventArgs.ErrorText and ASPxClientUploadControlFileUploadCompleteEventArgs.errorText allow you to set the custom error text if the upload control's validation fails.

Note that the UploadControlValidationSettings.AllowedFileExtensions property is used only for validating the uploaded file's extension. The UploadControlValidationSettings.AllowedFileExtensions property does not allow you to customize the appearance of the File Extension filter in the Open File dialog window. The browser determines and controls the list of file extensions in the File Extension filter.

Expanded Examples

  1. The following example illustrates how to customize an error message for files that failed the validation using the ASPxClientUploadControl.ValidationErrorOccurred event.

  2. The following example shows how to restrict uploading files without extension on the client side.

Is this topic helpful?​​​​​​​