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

Ajaxed Grid, button export PDF to http response

5 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul J
Top achievements
Rank 1
Paul J asked on 10 Aug 2011, 06:59 PM
is this possible?

I've hooked a regular postback event to the button click of the button within the ajaxed grid. still gives me the following error:

Line: 6
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 '%PDF-1.2
%��
1 0 ob'.

code:

<script type="text/javascript">
function realPostBack(eventTarget, eventArgument) {
 
__doPostBack(eventTarget, eventArgument);
}
 
</script>

<telerik:GridTemplateColumn UniqueName="templateColPrint" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="45px" HeaderText="Print" HeaderStyle-HorizontalAlign="Center">
                                  
                <ItemTemplate>
                        <asp:Button runat="server" Text="" ID="btnPrint" CommandName="PrintReceipt" CssClass="btnPrintIcon" />                 
                </ItemTemplate>
                </telerik:GridTemplateColumn>
Protected Sub SearchGrid_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles SearchGrid.ItemCreated
 
    If (TypeOf e.Item Is GridDataItem) And e.Item.OwnerTableView.Name = "ReceiptNumber" Then
        Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
 
        Dim button1 As Button = CType(dataItem("templateColPrint").FindControl("btnPrint"), Button)
        
        button1.Attributes.Add("onclick", String.Format("realPostBack('{0}', '{1}');", button1.UniqueID, button1.CommandArgument))
 
    End If
 
 
 
End Sub
 
 
 
Protected Sub SearchGrid_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles SearchGrid.ItemCommand
 
    Select Case e.CommandName
               Case "Print"
            CreatePDFReport(CType(SearchGrid.MasterTableView.DataKeyValues.Item(e.Item.ItemIndex)("Number"), Integer))
        Case Else
            Exit Sub
    End Select
   
End Sub

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 15 Aug 2011, 03:25 PM
Hi Paul J,

Please try using the following approach and let me know if this works:
Protected Sub Page_Load(sender As Object, e As EventArgs)
    ScriptManager1.RegisterPostBackControl(btnPrint)
End Sub

You could also review the following help topic which elaborates on exporting from ajaxified Grid.


All the best,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start 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
Paul J
Top achievements
Rank 1
answered on 15 Aug 2011, 09:32 PM
Okay, so since my buttons exist within a grid, I tried what you suggested, using the code within the ItemCreated event. But it did not work. Any other suggestions?
0
Maria Ilieva
Telerik team
answered on 17 Aug 2011, 02:48 PM
Hi Paul,

Could you please refer to the following online demo which presents the same functionality you are trying to achieve. Test the provided approach and let me know if it works for you.

Kind regards,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start 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
Paul J
Top achievements
Rank 1
answered on 17 Aug 2011, 02:58 PM
No, I don't believe it's quite the same scenario. I'm not trying to export the contents of the grid. Each row of my grid has a print button. when the print button is pressed, it runs some codebehind that generates a PDF report (actually uses Crystal Reports). I want it to then serve up the PDF to the user as a typical open / save/ cancel dialog. I have it working outside of the grid -- it sends the pdf as part of the HTTP Response.

I want to achieve this same results directly from the print button of each row of an ajaxified grid. but none of what I've tried has worked.
I also have a radajaxmanagerproxy on my page that the grid exists on.

thanks.

FYI, i went ahead and tried the demo's method of using the OnRequestStart to set the ajax of the button to false, but I'm still getting the original error.
0
Maria Ilieva
Telerik team
answered on 22 Aug 2011, 12:42 PM
Hi Paul,

Actually the custom approach you are implementing to export the RadGrid content is not supported out of the box and I could not be sure what exactly is causing the described problem. Could you please let me know if the mentioned approach runs correctly with regular asp GridView control and asp UpdatePanel instead of RadAjaxManager control.
Also could you please provide us some more explanation on the exact method you are using to print specific Grid row. Some code related to the functionality could help us further research on the problem you are facing.


Best wishes,
Maria Ilieva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Paul J
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Paul J
Top achievements
Rank 1
Share this question
or