RadAjax with Response.Write to download String into a Excel file

4 posts, 0 answers
  1. Lorenzo
    Lorenzo avatar
    14 posts
    Member since:
    Oct 2010

    Posted 26 Nov 2010 Link to this post


    I have the same problem:
    My asp:ImageButton is inside a telerik:RadAjaxManager and do the same code:

    HttpContext.Current.Response.AddHeader( "content-disposition", string.Format( "attachment; filename={0}", "ElencoCandidati.xls" ) );
    HttpContext.Current.Response.ContentType = "application/ms-excel; charset=utf-8";
    HttpContext.Current.Response.Write( wResult );

    Without the telerik:RadAjaxManager work fine but when i run my website with a telerik:RadAjaxManager I have the same error:

    Line: 938
    Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
    Details: Error parsing near '<html xmlns:o="urn:s'.

    What can I do?

    Thanks in advance!

  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 26 Nov 2010 Link to this post

    Hello Lorenzo,

    You need to remove your ImageButton from the RadAjaxManager or performing a ajax request because you cannot make calls to the Response object when using ASP.NET Ajax.
  3. Daniel
    Daniel avatar
    4949 posts

    Posted 26 Nov 2010 Link to this post

    Hello Lorenzo,

    Cori is right, this functionality will work with normal postback only. If your export button is nested within another ajaxified control I recommend that you use the following approach to sidestep the problem:
    Export from ajaxified grid

    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  4. Lorenzo
    Lorenzo avatar
    14 posts
    Member since:
    Oct 2010

    Posted 29 Nov 2010 Link to this post

    Thanks a lot to all!

    Finally I use the onRequestStart client method in the same mode:

    function onRequestStart(sender, args)
       if (args.get_eventTarget().indexOf("ctl00$MainContent$m_btn_ExportQuestionnaireResult") != -1)

    <telerik:RadAjaxManager ID="m_ram_AjaxManager" runat="server" ClientEvents-OnRequestStart="onRequestStart">
        <ClientEvents OnRequestStart="onRequestStart" />

Back to Top