Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Upload / How to Prevent upload on subsequent upload Button clicks

How to Prevent upload on subsequent upload Button clicks

Article Info

Rating: 5

Article information

Article relates to

 RadUpload for ASP.NET AJAX Q2 and later

Created by

 Simon, Telerik

Last modified by

 Simon, Telerik


ISSUE
Subsequent clicks on the upload Button on a page can cause files to be submitted more than once.

RESOLUTION
Cancel form submission if the file upload has already started.

[ASPX]
<body> 
 
    <script type="text/javascript"
        var uploadIsInProgress = false
         
        function clientProgressStarted(sender, eventArgs) { 
            uploadIsInProgress = true
        } 
         
        function doUpload() { 
            if (uploadIsInProgress) { 
                return false
            } 
             
            return true
        } 
    </script> 
 
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <div> 
            <telerik:RadUpload ID="RadUpload1" runat="server"  
                TargetFolder="~/Files"></telerik:RadUpload> 
            <telerik:RadProgressArea ID="RadProgressArea1" runat="server"></telerik:RadProgressArea> 
            <telerik:RadProgressManager ID="RadProgressManager1" runat="server"  
                OnClientProgressStarted="clientProgressStarted" /> 
            <asp:Button ID="Button1" runat="server" Text="Upload" /> 
        </div> 
    </form> 
</body> 

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.