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

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

3 Answers 461 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lorenzo
Top achievements
Rank 1
Lorenzo asked on 26 Nov 2010, 05:47 PM
Hi!

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

HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
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 );
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();

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!


Francesco

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 26 Nov 2010, 06:17 PM
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.
0
Daniel
Telerik team
answered on 26 Nov 2010, 10:48 PM
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

Regards,
Daniel
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.
0
Lorenzo
Top achievements
Rank 1
answered on 29 Nov 2010, 10:19 AM
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)
      args.set_enableAjax(false);
}

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


Francesco
Tags
Ajax
Asked by
Lorenzo
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Daniel
Telerik team
Lorenzo
Top achievements
Rank 1
Share this question
or