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

Downloading a file and the trigger is associated with rad ajax manager

3 Answers 386 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Arsalan
Top achievements
Rank 1
Arsalan asked on 22 Mar 2013, 06:55 AM
i am experiencing a problem while downloading files  through rad controls

okai i have a button that is called generate presentation , the button is inside rad ajax panel  , so when the button is pressed  an asynchronous post back goes to server   and the uploading panel becomes visible .  on server  i use  the following  code to  transmit the file to the user who can then download it

 string fileNameToDisplay =  TrimNonCompliantStrings();
               
                   string virtualPath = @"~\" + newPresentationDoc.Replace(HttpContext.Current.Request.PhysicalApplicationPath, String.Empty);
             //   Response.End();

                   RadAjaxPanel1.ResponseScripts.Add(String.Format(@"window.location.href = ""{0}"";", virtualPath));

but nothing really happens when the response is sent from the server  it just closes the update panel and no download dialog is shown  previously before ajaxifying  i was using the  following appraoch ,  and it was working fine


    Response.ContentType = "application/octet-stream";
                 Response.AppendHeader("Content-Disposition", "attachment;filename=" +fileNameToDisplay );   //+ ".pptx"
                   Response.AppendHeader("Content-Disposition", "attachment;filename=" + "babe" + ".pptx");  
    Response.TransmitFile(virtualPath);
      Response.End();

i know a workaround where i can disable ajax request by replacing it with a full blown request to download the file , but by that i l loose the upload panels preloader ....  , How can i resolve this issue 


here is the markup

 <telerik:AjaxSetting AjaxControlID="btn_Generate">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
               
  <telerik:AjaxSetting AjaxControlID="btnPublish">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1"  />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
    </AjaxSettings>




                

  
 
      

             
               

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 27 Mar 2013, 09:44 AM
Hi Arsalan,

I tried to reproduce the described issue but to no avail. On my side the RadAjaxPanel1.ResponseScripts.Add() works as expected. I am sending you a simple example, please check it out and let me know what differs in your case.

Looking forward for your reply.

Greetings,
Radoslav
the Telerik team
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 their blog feed now.
0
Sivajith
Top achievements
Rank 1
answered on 28 Dec 2013, 10:04 AM
hi,

I also come across this problem. What i experienced is i will generate a pdf file or zip file based on conditions and download it. but when rad ajaxmanager and loading panel are used it won't work. the code executes but the download not happens. one more thing , i downloaded your sample and it works fine with docx and I added a pdf file then it openup in that page..why this happens?
 
0
Konstantin Dikov
Telerik team
answered on 02 Jan 2014, 11:53 AM
Hi Sivajith,

What you are describing is the default browser behavior. I have modified the sample page that was previously attached, so it could force the download of PDF file. 

Please note that this will only if you temporarily disable the AJAX on button click.

Additionally, you could have a look at the following articles that could prove helpful:

Hope that helps.


Regards,
Konstantin Dikov
Telerik
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.
Tags
Ajax
Asked by
Arsalan
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Sivajith
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or