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

4 posts, 0 answers
  1. Arsalan
    Arsalan avatar
    7 posts
    Member since:
    Jun 2012

    Posted 22 Mar 2013 Link to this post

    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>




                    

      
     
          

                 
                   
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 27 Mar 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sivajith
    Sivajith avatar
    4 posts
    Member since:
    Nov 2013

    Posted 28 Dec 2013 Link to this post

    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?
     
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 02 Jan 2014 Link to this post

    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.
Back to Top