Handle Select Button Event in Code-behind

2 posts, 0 answers
  1. Randy
    Randy avatar
    12 posts
    Member since:
    Jan 2012

    Posted 03 Jun 2013 Link to this post

     I have an aspx.cs page which uploads the RadAsyncUpload UploadedFiles collection to Azure per the following button click event. I've been asked to upload the files automatically, as soon as the user hits the RadAsyncUpload Select button, rather than having an extra button on the page, but not sure how to do this. Any help with this would be greatly appreciated.
    I need to run code similar to the below....

    protected void btnAttachFiles_Click(object sender, EventArgs e)
        Boolean isUploaded = false;
        for (int i = 0; i <= RadAsyncUpload1.UploadedFiles.Count - 1; i++)
                Telerik.Web.UI.UploadedFile file = RadAsyncUpload1.UploadedFiles[i];
                // upload file to azure
                byte[] fileDataByteArray = new byte[file.InputStream.Length];
                file.InputStream.Read(fileDataByteArray, 0, (int)file.InputStream.Length);
                isUploaded = myAzure.UploadBlob(fileDataByteArray, RadAsyncUpload1.UploadedFiles[i]);
            catch (Exception exc)
                lblError.Text = exc.Message;


    Thank you very much,
    Randy Sullivan

  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 06 Jun 2013 Link to this post

    Hi Randy,

    Handle the OnClientFilesSelected event and simulate a button click:

    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnClientFilesSelected="OnClientFilesSelected" />
          <telerik:RadButton ID="btnAttachFiles" runat="server" Text="Attach Files" OnClick="btnAttachFiles_Click" Visible="false"/>

    function OnClientFilesSelected(sender, args) {

    protected void btnAttachFiles_Click(object sender, EventArgs e)

    Hristo Valyavicharski
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top