cancel
Showing results for 
Search instead for 
Did you mean: 

Detect Print/Export Event Crystal Report Viewer Control on ASPX

Former Member
0 Kudos

Hello,

I do not see the event in Crystal Report Viewer control to capture event when Print or Export button was clicked.

Clicking these two buttons will create HTTP post back to ASPX web page. I can see this result using Fiddler.

__EVENTTARGET and __EVENTARGUMENT have values

This code work i.e. if I want to attach any code for control when Search button is clicked

Please refer to code sample I provided. For some reasons I could not insert the C# code using Insert option.

Thank you.

Serghei

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

<head runat="server">

    <title>FIM Report</title>  

    <script src="../../../../../../Scripts/jquery-1.10.2.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {         

            document.getElementById("crViewer_toptoolbar_print").addEventListener("click", printEvent);

            document.getElementById("crViewer_toptoolbar_export").addEventListener("click", exportEvent);

            function printEvent() {

                //add logic here this is just a test

                alert('Print button was clicked');

            }

            function exportEvent() {

                //add logic here this is just a test

                alert('Export button was clicked');

            }

        });

    </script>        

</head>

I understand that user can click Cancel button and not going to send document to the printer, but at least I can capture the event.

I solved the problem by using this code.

Without JQuery the code is not going to work because CR print button do the POST. Event should be executed when HTML document is completely loaded.

Hopefully it will save your time if for some reasons you need this functionality.

Answers (1)

Answers (1)

Former Member
0 Kudos

<script src="../../../../../../Scripts/jquery-1.10.2.min.js"></script>

<script type="text/javascript">

    $(document).ready(function () {     

        $("#crViewer_toptoolbar_print").click(function () {

            console.log('Print button was clicked');

        });

        $("#crViewer_toptoolbar_export").click(function () {

            console.log('Export button was clicked');

        });

    });

</script>

Or jQuery only