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

How to Hide Progress bar on Cancel button click event?

7 Answers 569 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Aswath
Top achievements
Rank 1
Aswath asked on 28 Jul 2009, 06:20 AM
Hi All,

I am facing a new problem with RadProgressArea control. If i browse any file and on clicking Cancel button Progress bar is showing. How to hide/remove progress bar when user is clicking any button other than Upload button?

7 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 28 Jul 2009, 04:33 PM
Hello Aswath,

Is your Cancel button a submit one? If so, this behavior is expected. RadUpload, as well as the standard ASP.NET FileUpload, starts uploading whenever an input is pressed. There is a workaround to this issue, but you need to replace the cancel button with a standard button or with a link button. Is this applicable in your case? By standard button I mean the following:

<asp:Button runat="server" ID="BtmCancel" Text="Cancel"  UseSubmitBehavior="false"/> 


Regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Aswath
Top achievements
Rank 1
answered on 29 Jul 2009, 05:22 AM
Hi Genady Sergeev,

Thanks for ur reply.

My Cancel button is a submit one. On click of cancel button i am clearing all the fields in my form. I tried your logic by placing a normal button but still i am getting progress bar.

Any help....................

Thanks.
0
Genady Sergeev
Telerik team
answered on 29 Jul 2009, 01:42 PM
Hi Aswath,

Let's clarify a thing, is there a file selected in the RadUpload when the RadProgressArea shows up? If so, use the following code:

 <script type="text/javascript"
        function clearInputs() { 
            var upload = $find("<%= RadUpload1.ClientID %>"); 
                var fileInputs = upload.getFileInputs(); 
                for (var i = 0; i < fileInputs.length; i++) { 
                    upload.clearFileInputAt(i); 
                } 
        }    
     
    </script> 
 
<asp:Button runat="server" ID="btnCance" Text="Cancel" OnClientClick="clearInputs();" /> 

If there is no file selected in the RadUpload, could you verify that your RadProgressArea is not sitting inside an update panel?

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Aswath
Top achievements
Rank 1
answered on 29 Jul 2009, 02:27 PM
Hi Genady Sergeev,

Thanks for ur reply.

Yes, RadUpload had file when i am clicking Cancel button. I placed your code and checked but it is not working for me.

Here is my criteria: My form is very big and in bottom of the form i had RadUpload along with submit & cancel buttons. This total form is inside master page and inside Radajax panel. I placed seperate ajax panel (Ajaxpanel2) for radupload, submit & cancel btns. For Ajaxpanel2 im calling one function ClientEvents-OnRequestStart="OnRequestStart", before Cancel btns onclientclick event the above function is firing and progress bar is displaying. I can't place cancel btn out side 2nd ajaxpanel bcuz alinment will spoil. Submit & Cancel are both in the same row.

Plz help me.......
0
Genady Sergeev
Telerik team
answered on 03 Aug 2009, 11:21 AM
Hi Azoth,

Hook on the client submitting event of the RadProgressManager and use the following code:

 
<script type="text/javascript"
        function submit(sender, args) { 
            var prm = Sys.WebForms.PageRequestManager.getInstance(); 
            if (prm.get_isInAsyncPostBack) { 
                $telerik.$("#RadProgressArea1").css("display", "none"); 
            } 
        } 
         
    </script> 
 
<telerik:RadProgressManager runat="server" ID="RadProgressManager1" OnClientSubmitting="submit"  /> 

There is a bug with the progress area that happens intermittently. The bug is that when the form is in async postback the progress area shows. Perhaps, this is the issue that you are experiencing. The upper code should fix it.

Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Aswath
Top achievements
Rank 1
answered on 03 Aug 2009, 03:19 PM
Thanks.

Your code is hiding the progress bar, but still the process is running in the background ie i am uploading 1GB file so it is taking 5 mins to cancel the operation.
0
Genady Sergeev
Telerik team
answered on 04 Aug 2009, 07:56 AM
Hello Aswath,

If your cancel button triggers an asynchronous  postback, a file upload is not possible and your 1GB file shall not be uploaded. In fact, this is the case, since the progress area is being hidden:

 if (prm.get_isInAsyncPostBack) ... (code to hide the progress area).

What do you mean by a background process? Perhaps you see the RadProgressArea polling endlessly to the server? If this is the case, you can use the following workaround:

<script type="text/javascript"
     
        var prm = Sys.WebForms.PageRequestManager.getInstance(); 
        prm.add_beginRequest(beginRequestHandler); 
        var isInAsyncRequest; 
        var originalClientSubmit; 
         
        if (!originalClientSubmit) {        
            originalClientSubmit =  
                Telerik.Web.UI.RadProgressManager.prototype._clientSubmitHandler; 
        }           
         
        function pageLoad() { 
            isInAsyncRequest = false
        } 
 
        Telerik.Web.UI.RadProgressManager.prototype._clientSubmitHandler = function(e) { 
            if (!isInAsyncRequest) { 
                originalClientSubmit.apply(this, [e]); 
            } 
        } 
</script 

Place the upper code right after your script manager declaration.

Regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Upload (Obsolete)
Asked by
Aswath
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Aswath
Top achievements
Rank 1
Share this question
or