Blogs

News

Email Subscriptions

Mehul Harry's DevExpress Blog

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

     

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

Published Mar 29 2011, 09:15 AM by Mehul Harry (DevExpress)
Technorati tags: Features, v2011.1, ASPxperience, ASP.NET
Bookmark and Share

Comments

No Comments

About Mehul Harry (DevExpress)

Mehul Harry is an ASP.NET technical evangelist at Developer Express. You can reach him directly at mharry@DevExpress.com. You can also follow him on Twitter: http://twitter.com/mehulharry
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.