This is a migrated thread and some comments may be shown as answers.

Customize Upload

3 Answers 106 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chen
Top achievements
Rank 1
Chen asked on 31 Jul 2012, 01:51 PM
Hi,

I have two questions about the upload.

 

  1.  Is there any way to custom upload so that I can open a file by clicking on the file item in the upload (see the attachment)?
  2. After upload files, can we remove one or more files in the list (see the attachment too)?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 01 Aug 2012, 04:01 PM
Hi Chen, 

Let me get straight to your questions:

1. open a file by clicking on the file item in the upload  - The RadUploadItems don't expose a Click event so you can either handle the RadUpload.SelectionChanged event to open the files or attach a handler for the MouseLeftButtonUp event on the RadUploadItems:
this.AddHandler(RadUploadItem.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnItemClicked),true);

void OnItemClicked(object sender, MouseButtonEventArgs e)
{
    RadUploadItem item = (e.OriginalSource as FrameworkElement).ParentOfType<RadUploadItem>();
    if (item != null)
    {
        foreach (RadUploadSelectedFile file in xRadUpload.CurrentSession.SelectedFiles)
        {
            if (file.Name == item.FileName)
            {
                //implement your logic that opens the files
            }
        }
    }
}

2. After upload files, can we remove one or more files in the list - You can edit the default Metro style of the RadUploadItems to make sure that the Close button element is always visible. By default its Visibility property is controlled through one private property so you can just edit its definition to remove the Visibility property at all.  

I attached a sample solution to get you started.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Chen
Top achievements
Rank 1
answered on 02 Aug 2012, 03:31 PM
Hi Tina,

Thanks a lot for your reply. I'll try your sample code.

This leads to another question. How can I open file per file type?

Let's say a user browsed and selected a .txt file, a .doc file and a.jpg file. When the user click on the .txt file, .doc file, or the .jpg file, I would like to open it in notepad.exe, MS Word.exe or Paint.exe respectively. How can I do it in silverlight?

Thanks again.
Chen
0
Tina Stancheva
Telerik team
answered on 07 Aug 2012, 06:55 AM
Hello Chen,

As opening a file in an external program is a scenario that falls outside the RadControls scope, you can try to find suitable approaches around the net.

The following links can give you ideas on how to get started:

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Upload
Asked by
Chen
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Chen
Top achievements
Rank 1
Share this question
or