WebForms AsyncUpload Overview
This article gives a quick overview of the RadAsyncUpload control and shows the steps to declare it. We also describe some of the major features of RadAsyncUpload that was introduced in Q1 2010 with UI for ASP.NET AJAX 2010.1.309.
RadAsyncUpload looks like the regular RadUpload control but offers an asynchronous upload capability. The upload process requires that the files are uploaded to a custom handler and not to the hosting page. The uploaded files are stored in a temporary location until a postback occurs. The temporary files are deleted after a set amount of time defined by the TemporaryFileExpiration property. The default value is 4 hours.
The Async Upload is part of Telerik UI for ASP.NET AJAX, a
professional grade UI library with 120+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
The Async Upload is part of Telerik UI for ASP.NET AJAX, a professional grade UI library with 120+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
Get started with the RadAsyncUpload
- Ensure you have a script manager on the page (use <asp:ScriptManager> tag to declare one).
- Use the <telerik:RadAsyncUpload> tag to declare the control and specify the file upload folder by setting the TargetFolder property.
<telerik:RadAsyncUpload RenderMode="Lightweight" ID="RadAsyncUpload1" TargetFolder="Uploads" AllowedFileExtensions=".jpeg,.jpg,.png,.doc,.docx,.xls,.xlsx" runat="server"></telerik:RadAsyncUpload>
For more information on setting up the environment see the First Steps article.
RadAsyncUpload relies on saving temporary files. When posted, files are saved to the designated temp folder (App_Data/RadUploadTemp by default) with unique names. Once a postback occurs, RadAsyncUpload fires the OnFileUploaded event for each file. The target file is passed as part of the arguments to the event and can be set as either valid (default) or invalid. After the events fire, all files marked as valid are automatically saved to the TargetFolder if it’s set.
Finally, all processed temporary files are deleted. Temporary files are also deleted after a set amount of time defined by the TemporaryFileExpiration property.
With the release of Q1 2011 SP2, RadAsyncUpload supports setting the temporary folder globally in the appSettings section of the web.config. < add key="Telerik.AsyncUpload.TemporaryFolder" value="[path_to_the_temporary_folder]" /> The path can be relative or absolute.
Validation for RadAsyncUpload differs from validation in RadUpload as now it is possible to validate the file size on the client, as long as the File API upload module is used or there is Silverlight or Flash installed on the client's browser. If the validation fails, RadAsyncUpload will fire OnClientValidationFailed.
Different Built-In Upload Modules
Internally, RadAsyncUpload can choose between four modules for uploading - File API, IFrame, Flash and Silverlight. The module with the highest priority and most features supported is File API. The Silverlight and Flash modules are a fallback if File API is not supported. The final fallback is an upload using the IFrame module supported in all browsers.
In web farms, each server will need to use the same MachineKey that RadAsyncUpload uses for encryption. Most web farms should already have their MachineKeys synchronized as this is the recommended approach for web farm deployment. For more information see the How to integrate RadControls for ASP.NET AJAX in a WebFarm or WebGarden scenario blog post.
Maximum File Size
One of the benefits of RadAsyncUpload is that it allows you to upload files bigger than 2GB. See Uploading Large Files for more details.