How to build a simple upload application
|
Article relates to
|
RadUpload for Silverilght
|
|
Created by
|
Ivan Efimov
|
|
Last modified
|
September, 29, 2010
|
|
Last modified by
|
Tina Stancheva
|
How to build a simple upload application?
- You need a Silverlight application where to implement the RadUpload control. This is a standard procedure for creating a Silverlight application. Create the accompanying Web application as the wizard proposed.
- Place one RadUpload control
in the SL application's page and set its properties. You can also initialize the RadUpload's properties directly in the xaml code, this is a very flexible approach:
- UploadServiceUrl="http://localhost/RadUploadExample/SampleUploadHandler.ashx";
- TargetFolder="UserUploads";
- OverwriteExistingFiles="True";
- IsAutomaticUpload="false";
Please note you can use an absolute or a relative address of the upload service. Below is description of their application and some points you should be aware of:
- Absolute address: UploadServiceUrl="http://localhost/RadUploadExample/SampleUploadHandler.ashx";
Pros: In this case your application is able to do a cross-domain upload.
Cons: When you develop and test the application with a Localhost URL you should change it to point to the real domain before the deployment.
- Relative address: UploadServiceUrl="~/SampleUploadHandler.ashx";
Pros: There is no need to change the upload URL at development, Test and Production stages.
Cons: You cannot upload cross-domain. The upload handler should reside locally in same domain as the Silverlight application.
Special commands: "~/" - the root of the hosting Web application; "../" - parent directory.
Note: The path is relative to the Silverlight application.
- Go to the Web application project already created by the Wizard and:
- Create a new Folder in the project tree - call it UserUploads.
- Open the project's property page (select the web project in the solution explorer and press Shift+F4 or choose the Property Page from the View menu). Select the Web page and choose the Use Local IIS Web server. For the purpose of the example set the Project Url to
http://localhost/RadUploadExample
Save the settings: the Virtual directory will be created.
- Create the upload handler in the Web application:
- Add new Generic Handler - call it SampleUploadHandler.ashx;
- Open the handler's code behind file (SampleUploadHandler.ashx.cs) and simplify it's content to
| using System; |
using System.Web;
using Telerik.Windows;
|
| |
| namespace SilverlightApp.Web |
| { |
| public class SampleUploadHandler: RadUploadHandler |
| { |
| } |
| } |
- Build and run the Web application.
- Test the upload - select some files to upload and check inside the UserUploads folder for uploaded files.
Attached you can find an example project where all the mentioned points
above are implemented.
A detailed information about the RadUpload control can be found in the documentation.
Comments
If you'd like to comment on this KB
article, please, send us a
Support Ticket.
Thank you!
Please
Sign In
to rate this article.