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

Setting the TargetFolder property

6 Answers 132 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 20 Aug 2008, 11:49 AM
Hi,

I'm setting the TargetFolder property in the code-behind and I've noticed that setting it in the FilesSelected event is the only way I can get  it to work.

If I set it anywhere else (UploadBtn_Click, UploadStarted event) then the RadUAG_targetFolder form item in the handler always picks up the value set in the XAML.

Is there a reason for this or am I doing something wrong?

An example is:

radUploader.TargetFolder = (alreadyEncoded) ? "Videos" : "Encoding"


Best regards,

Ryan.

6 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 20 Aug 2008, 05:52 PM
Hello Ryan,

Yes - setting the TargetFolder in the UploadStarted event is too late because the request is already prepared.

What is your scenario? Why you need to to set the TargetFolder property in this event?

Sincerely yours,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ryan
Top achievements
Rank 1
answered on 21 Aug 2008, 08:50 AM
My scenario is a video upload, some of which are encoded on the server (so go into a folder to be picked up for encoding), some are pre-encoded by the user (so go directly to the encoded folder).

I don't need to set it in the Upload_Started event... it just needs setting when the upload button is clicked (but before the upload actually commences).

I've tried putting it in UploadButton_Click, but this has no effect either.

Kind regards,

Ryan.
0
Valentin.Stoychev
Telerik team
answered on 25 Aug 2008, 12:34 PM
Hello Ryan,

First of all - sorry for the much delayed answer!

The latest event that you can use to set the TargetFolder property is the "FilesSelected" event. After that the request is build and the new value for TargetFolder property will not be sent to the server. Do you think it will be better if we allow the setting of TargetFolder when the UploadStarted event is fired?

Kind regards,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jean-Pierre Fouche
Top achievements
Rank 1
answered on 05 Mar 2010, 01:00 PM

1.   I am curious as to why the target folder is being set in the client. 
2.   I am setting it on the server in the handler, using the following code. It does not work.   Please could you advise me.

<%

@ WebHandler Language="C#" Class="RadUploadHandler" %>

 

using

 

System;

 

using

 

System.Web;

 

public

 

class RadUploadHandler: Telerik.Windows.RadUploadHandler

 

{

 

     public RadUploadHandler()

 

     {

 

        string virtualFolder = System.Configuration.ConfigurationManager.AppSettings["FileUploadVirtualFolder"];

 

 

        this.TargetPhysicalFolder = HttpContext.Current.Server.MapPath(virtualFolder);

 

     }

 

 

}

 

 

0
Jean-Pierre Fouche
Top achievements
Rank 1
answered on 05 Mar 2010, 01:21 PM
Answering my own question, you need to override string GetTargetFolder().  Here is the code I used to fix the problem:

<%

@ WebHandler Language="C#" Class="RadUploadHandler" %>

 

using

 

System;

 

using

 

System.Web;

 

public

 

class RadUploadHandler: Telerik.Windows.RadUploadHandler

 

{

 

public override string GetTargetFolder()

 

{

 

string virtualFolder = System.Configuration.ConfigurationManager.AppSettings["FileUploadVirtualFolder"];

 

 

string output = HttpContext.Current.Server.MapPath(virtualFolder);

 

 

this.TargetPhysicalFolder = output;

 

 

return output;

 

}

}

It does not work if you use the same code in the constructor.

0
Ivan
Telerik team
answered on 08 Mar 2010, 10:40 AM
Hello Jean-Pierre,

Thank you for your interest in the RadUpload control.

Actually the right approach is overriding the GetTargetFolder method.

All the best,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Upload
Asked by
Ryan
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Ryan
Top achievements
Rank 1
Jean-Pierre Fouche
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or