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

How to change TargetFolder property?

2 Answers 233 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
jnh999
Top achievements
Rank 1
jnh999 asked on 29 Jan 2014, 08:59 PM
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 Answers, 1 is accepted

Sort by
0
jnh999
Top achievements
Rank 1
answered on 31 Jan 2014, 03:31 PM
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.
0
Hristo Valyavicharski
Telerik team
answered on 31 Jan 2014, 03:43 PM
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.
Tags
AsyncUpload
Asked by
jnh999
Top achievements
Rank 1
Answers by
jnh999
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or