ASP.NET File Manager - Validate File Uploads and Selected File Enhancements (available now in v2011.1)

ASP.NET Team Blog
29 March 2011

ASPxFileManager for ASP.NETThe DevExpress ASP.NET File Manager now has more enhancements in the DXperience v2011 volume 1 release.

Two more to be specific:

  1. Process and validate the stream of uploaded files
  2. New Server-side FileClick event

Validate File Uploads

We've enhanced the server-side FileUploading event so it'll give you the chance to process and validate the name and stream of the uploaded file.

How? By adding 3 new arguments for the FileUploading event:

  • public Stream InputStream { get; } // stream of the original upload file
  • public Stream OutputStream { get; set; } // is null, but you can set this property and change the original file content on the server side
  • public string FileName { get; set; } // uploaded file name. can be changed

FileName can be used to assign a new file name of the uploaded file.

These new arguments will let you inspect the uploaded file's stream and name properties and decide whether the file should be allowed to upload or canceled.

For example:

protected void ASPxFileManager1_FileUploading(object source, 
      DevExpress.Web.ASPxFileManager.FileManagerFileUploadEventArgs e) {
   if(e.InputStream.Length > 100000) {
      e.Cancel = true;
      e.ErrorText = "Error. File size exceeds 100kb";
   }
}

Selected File Event Enhancements

Two new items have been to help you deal with selected files in the ASPxFileManager:

1. A new server-side event called SelectedFileOpened will help you process double-click and the enter key being pressed on a selected file.

  • SelectedFileOpened Event - Argument's members: FileManagerFile file - If the event has a handler function then double click on the file and Enter pressing will be processed on the server

2. A new 'processOnServer' property has been added to the argument of client-side 'SelectedFileOpened' event. Therefore…

// pseudo-code :)
//
// If server-side event has the handler then {
//   processOnServer == true  /* by default */
// else 
//   processOnServer == false
// }

From Your Suggestions

Since the ASPxFileManager was announced, we're received great feedback from you. And your feedback has helped improve the ASPxFileManager for the upcoming DXperience v2011 volume 1 release.

  • S36849 - ASPxFileManager - Add a new file content parameter to the FileUploading event
  • S135872 - ASPxFileManager - Implement server-side FileClick event
  • Q298718 - ASPxFileManager - Server-side event for selecting file action

Thanks!

DXperience? What's That?

DXperience is the .NET developer's secret weapon. Get full access to a complete suite of professional components that let you instantly drop in new features, designer styles and fast performance for your applications. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

Follow MehulHarry on Twitter

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.