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

Cannot download file from Ajaxified button

1 Answer 54 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Vishnu
Top achievements
Rank 1
Vishnu asked on 17 Jul 2014, 01:47 PM
Hi,

There is an ASP button in the Content page of my web application and its ajaxified using the RadAjaxManagerProxy. In the server side click event of the button, I am trying to download a csv file.

When the button is ajaxified, the csv file is not getting downloaded and I noticed that the void Application_Error(object sender, EventArgs e) in Global.asax is firing on putting a break point.  If I remove the ajax from the button, then the code works fine as expected.

Here is a complete sample of my scenario.

Thanks,
Vishnu.

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 22 Jul 2014, 08:40 AM
Hello Vishnu,

This is a standard limitation when AJAX is enabled, which prevents file downloading in such manner.

In order to allow the download you will need to temporarily disable the AJAX. This could be easily achieved by handling the client-side OnRequestStart event of RadAjaxManager. Following is a very simple example demonstrating how to disable AJAX for a particular control:
<telerik:RadCodeBlock runat="server">
    <script type="text/javascript">
        function requestStart(sender, args) {
            if (args.get_eventTarget().indexOf("Button1") >= 0) {
                args.set_enableAjax(false);
            }
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadAjaxManager ID="ajaxManagerProxy" runat="server" ClientEvents-OnRequestStart="requestStart">
    <AjaxSettings>
    ....

In your particular scenario you could just remove the RadButton from the AJAX settings, but in more complex scenario, the above approach must be used.

Hope this helps.
 

Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Ajax
Asked by
Vishnu
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or