How to change TargetFolder property?

3 posts, 0 answers
  1. jnh999
    jnh999 avatar
    29 posts
    Member since:
    Apr 2010

    Posted 29 Jan 2014 Link to this post

    Hi Telerik,
    I need to change the TargetFolder property of the RadAsyncUpload control dynamically.  I extended AsyncUploadConfiguration class and populated the TargetFolder property in the code behind.  I wish to be able to access this property in the AsyncUploadHandler class before the file is saved on the server.  But the property does not get passed to the handler for whatever reason.   

    Thanks for any help.

     

  2. jnh999
    jnh999 avatar
    29 posts
    Member since:
    Apr 2010

    Posted 31 Jan 2014 in reply to jnh999 Link to this post

    I followed this sample code http://www.telerik.com/help/aspnet-ajax/asyncupload-extending-handler.html
    but the configuration property does not get passed to the handler.  I feel this has something to do with the postback of RadAsyncUpload control.  Can anyone show some working example code?  Thanks.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 31 Jan 2014 Link to this post

    Hi,

    easiest way to set the Target folder dynamically is to set it in the OnFileUploaded event or on a button click:

    aspx
    <telerik:RadAsyncUpload
           ID="RadAsyncUpload1"
           OnClientFileUploadFailed="OnClientFileUploadFailed"
           OnClientValidationFailed="OnClientValidationFailed"
           AllowedFileExtensions="xps,pdf,docx,xlsx"
           runat="server">
       </telerik:RadAsyncUpload>
       <telerik:RadButton ID="rbUpload" runat="server" Text="Upload" OnClick="rbUpload_Click"></telerik:RadButton>

    cs
    protected void rbUpload_Click(object sender, EventArgs e)
    {
        string target = Server.MapPath("~/Uploads/");
     
        foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
        {
            file.SaveAs(target + file.FileName);
        }
    }


    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top