Setting the TargetFolder property

7 posts, 0 answers
  1. Ryan
    Ryan avatar
    7 posts
    Member since:
    Aug 2008

    Posted 20 Aug 2008 Link to this post

    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.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 20 Aug 2008 Link to this post

    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.
  3. DevCraft banner
  4. Ryan
    Ryan avatar
    7 posts
    Member since:
    Aug 2008

    Posted 21 Aug 2008 Link to this post

    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.
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 25 Aug 2008 Link to this post

    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.
  6. Jean-Pierre Fouche
    Jean-Pierre Fouche avatar
    2 posts
    Member since:
    Mar 2010

    Posted 05 Mar 2010 Link to this post

    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);

     

         }

     

     

    }

     

     

  7. Jean-Pierre Fouche
    Jean-Pierre Fouche avatar
    2 posts
    Member since:
    Mar 2010

    Posted 05 Mar 2010 Link to this post

    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.

  8. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 08 Mar 2010 Link to this post

    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.
Back to Top
DevCraft banner