printing from within an ajax panel causes javascript error

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 30 Dec 2011 Link to this post


    I have a radrid with one column setup for printing the object associated with the ID of the row.  Works great unless I ajaxify the grid either wrapping with an AJAX panel or using an ajax manager on the page then I get a javascript error on postback wchihc makes sense because the ajax manager or panel will be trying to interpret the response.  How to I bypass the ajax panel for this one behaviour and have the browser rather than the ajax manager respond to the new contect header information?
    protected void radGridAll_ItemCommand(Object sender, GridCommandEventArgs e)
                if (e.CommandName != "Print" ) return;
                Guid id = Guid.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
                //lblMessage.Text = string.Empty;
                switch (e.CommandName)
                    case "Print":
                        //string args = Request.QueryString["ApplicationID"];
                        NMotionServer.ApplicationLead _application = NMotionServer.ApplicationLeadService.GetByID(id);
                        if (_application.LeadStatusID == (int)enumLeadStatus.Fresh || _application.LeadStatusID == (int)enumLeadStatus.Viewed)
                            AppHistory _leadStatusEvent = new AppHistory() { ApplicationLeadID = _application.ID, EventTypeID = 2, ForeignKeyID = (int)enumLeadStatus.Printed, Timestamp = DateTime.Now, UserProfileID = ((UserProfile)Session["_userProfile"]).ID };
                            _application.LeadStatusID = (int)enumLeadStatus.Printed;
                        //RptApplication _applicationReport = new RptApplication((DealerLinkServer.SalesForceWebReference.SforceService)Session["SalesForceBinding"], args);
                        RptApplication _applicationReport = new RptApplication(id.ToString());
                        ReportProcessor _processor = new ReportProcessor();
                        RenderingResult result = _processor.RenderReport("PDF", _applicationReport, null);
                        string fileName = "NMotion_Lead_" + _application.ApplicantNameLast2First.Replace(" ", "_").Replace(",","_").Replace("'", "_") + "_" + _application.DateOfApplication.Year + _application.DateOfApplication.Month + _application.DateOfApplication.Day + ".pdf";
                        Response.ContentType = result.MimeType;
                        Response.Expires = -1;
                        Response.Buffer = true;
                        Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", fileName));


  2. Antonio Stoilkov
    Antonio Stoilkov avatar
    530 posts

    Posted 03 Jan 2012 Link to this post

    Hi Jonathan,

    Editing the Response Headers with ajax request is not supported. Your application need to fully reload the page in order for your scenario to work.

    All the best,
    Antonio Stoilkov
    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
Back to Top