More in this section

Forums / Developing with Sitefinity / Regular postbacks within AJAX?

Regular postbacks within AJAX?

2 posts, 0 answered
  1. Matthew Bonig
    Matthew Bonig avatar
    1 posts
    Registered:
    19 Aug 2009
    19 Aug 2009
    Link to this post
    I have a control I'm developing for my sitefinity based site. The site is almost all AJAX controls (using RAD and homegrown controls) except for one control in which the code-behind creates a PDF for the user to download. Currently the code looks something like this:
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; 
                response.Clear(); 
                response.AddHeader("Content-Type""binary/octet-stream"); 
                response.AddHeader("Content-Disposition""attachment; filename=TransactionHistory.pdf; size=" + pdfBytes.Length.ToString()); 
                response.Flush(); 
                response.BinaryWrite(pdfBytes); 
                response.Flush(); 
                response.End(); 

    where pdfBytes is a byte[].

    The problem I have right now is that when this code runs I get a javascript error:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
    Timestamp: Wed, 19 Aug 2009 18:32:09 UTC


    Message: 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 '%PDF-1.5
    %��
    1 0 o'.
    Line: 6
    Char: 62099
    Code: 0
    URI: <remove for brevity>


    so, how can I have this postback handled outside of AJAX and done through a normal POST command or how can I get the resulting response handled correctly on the client side?

    thanks!


  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 Aug 2009
    Link to this post
    Hello Matthew Bonig,

    Is this code placed in a user control? How do you use it? There is an approach showed in the following forum thread - http://forums.asp.net/t/1037846.aspx by implementing your own response filter and parser.

    Can you please try with the same control but outside a Sitefinity page?

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
2 posts, 0 answered