Upload button trigger?

Thread is closed for posting
2 posts, 0 answers
  1. Philip
    Philip avatar
    70 posts
    Member since:
    Apr 2008

    Posted 09 Sep 2009 Link to this post

    I am trying to use the radupload control, and am having trouble connecting the "submit" button to the control.

    After looking a the demos for this control, I can not see where the button is tied into the upload.

    It would appear that the button click is simply toggling the visibility of labels and such.

    How is the filexists fired? What controls it if I have multiple buttons in my page?

    Obviously I am missing something here, any help would be greatly appreciated.

    How does the code below trigger the file to be uploaded on the click of the button?


    <telerik:RadUpload
                                ID="RadUpload1" runat="server"
                                MaxFileInputsCount="5"
                                TargetFolder="~/Upload/Examples/UsingTargetFolder/MyFiles"
                                OverwriteExistingFiles="false" />




    <asp:Button id="buttonSubmit" runat="server" CssClass="RadUploadSubmit" OnClick="buttonSubmit_Click" text="Submit" />

     Protected Sub buttonSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                If RadUpload1.UploadedFiles.Count > 0 Then
                    repeaterResults.DataSource = RadUpload1.UploadedFiles
                    repeaterResults.DataBind()
                    labelNoResults.Visible = False
                    repeaterResults.Visible = True
                Else
                    labelNoResults.Visible = True
                    repeaterResults.Visible = False
                End If
                DeleteFiles()
            End Sub


    Protected Sub RadUpload1_FileExists(ByVal sender As Object, ByVal e As Telerik.Web.UI.Upload.UploadedFileEventArgs)
                Dim counter As Integer = 1
                Dim file As UploadedFile = e.UploadedFile
                Dim targetFolder As String = Server.MapPath(RadUpload1.TargetFolder)
                Dim targetFileName As String = Path.Combine(targetFolder, file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension())
                While System.IO.File.Exists(targetFileName)
                    System.Math.Max(System.Threading.Interlocked.Increment(counter),counter - 1)
                    targetFileName = Path.Combine(targetFolder, file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension())
                End While
                file.SaveAs(targetFileName)
            End Sub


  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 10 Sep 2009 Link to this post

    Hello Philip,

    Actually, RadUpload is not connected with any submit button. It is uploading with postbacks triggered by any control (that can postback).
    You can check this help topic on how to upload a file if only a particular button is clicked.

    Best wishes,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top