Skip to main content

UploadControlExtension.GetUploadedFiles(String, UploadControlValidationSettings, EventHandler<FileUploadCompleteEventArgs>) Method

Returns an array of the files uploaded via the specified UploadControl, and accepts specific parameters.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v23.2.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public static UploadedFile[] GetUploadedFiles(
    string name,
    UploadControlValidationSettings validationSettings,
    EventHandler<FileUploadCompleteEventArgs> fileUploadCompleteDelegate
)

Parameters

Name Type Description
name String

A string value specifying the UploadControl’s name (SettingsBase.Name).

validationSettings UploadControlValidationSettings

A UploadControlValidationSettings object that contains settings that relate to the uploaded file validation.

fileUploadCompleteDelegate EventHandler<FileUploadCompleteEventArgs>

A delegate method that implements custom validation of an uploaded file.

Returns

Type Description
UploadedFile[]

An array of UploadedFile objects associated with file input elements.

Remarks

Html.DevExpress().UploadControl(
    settings => {
        settings.Name = "uc";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "FileUploaded" };
        settings.ClientSideEvents.FileUploadComplete = "function(s, e){ if (e.isValid) htmlEdit.SetHtml(e.callbackData); }";
    })
    .Render();
public ActionResult FileUploaded() {
    UploadControlExtension.GetUploadedFiles("uc", new UploadControlValidationSettings() {
        AllowedFileExtensions = new String[] { ".html", ".htm", ".txt" }
    }, FileUploadComplete);
    return null;
}
protected void FileUploadComplete(object sender, FileUploadCompleteEventArgs e) {
    if (e.UploadedFile.IsValid) {
        e.CallbackData = System.Text.Encoding.UTF8.GetString(e.UploadedFile.FileBytes);
    }
}

Online Examples

View Example: How to upload a file

View Example: How to upload an Excel file using an upload control and display the file's data in the grid

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetUploadedFiles(String, UploadControlValidationSettings, EventHandler<FileUploadCompleteEventArgs>) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also