首页 文章

绑定客户端单击事件以在Asp.NET中打印Crystal Report Viewer控件的按钮

提问于
浏览
0

我有一个带有Crystal Report Viewer Control的ASP.NET页面 .

当一个报告呈现给客户端和客户 endpoints 击打印按钮(crystalReportviewer控件)时,我想询问用户是否正确打印报告(在日志中调用服务器/上传等) . )印刷结束后 .

Aspx的相关代码是:

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            GroupTreeImagesFolderUrl="" Height="1202px" 
            ReuseParameterValuesOnRefresh="True" EnableDatabaseLogonPrompt="false"
            ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" />

&页面底部的脚本 .

<script>
    document.getElementById("CrystalReportViewer1_toptoolbar_print").addEventListener("click", function () {
        var x = confirm("Did The Report Print properly ?");
        if (x) {
            //Do something...

        }
    });

</script>

问题是在打印对话框打开之前和任何打印活动之前触发此单击事件 . 此外,单击打印按钮时,查看器将触发回发以获取报告内容并打印到打印机 . So this approach does not work.

任何选项实现此功能?

Edit : 为打印按钮生成的HTML :(这是由水晶报表查看器控件生成的)

<table id="CrystalReportViewer1_toptoolbar_print" class="toolbar_button_default" cellspacing="0" cellpadding="0" border="0" role="button" style="height: 22px; margin: 1px; display: block; cursor: pointer;" tabindex="0" title="Print this report">

    <tbody>
        <tr valign="middle">
            <td>
                <div style="overflow:hidden;height:20px;width:20px;cursor:pointer">
                    <img id="IconImg_CrystalReportViewer1_toptoolbar_print" width="16" vspace="0" hspace="0" height="16" border="0" style="float: left; background-image: url("aspnet_client/system_web…ckground-position: -3px -25px; margin: 2px; cursor: pointer;" alt="Print this report" src="aspnet_client/system_web/4_0_30319/crystalreportviewers13/js/crviewer/../dhtmllib/images/skin_standard/../transp.gif"></img>
                </div>
            </td>
        </tr>
    </tbody>

</table>

A Screen Shot of the runtime events bubbled to it:
enter image description here

1 回答

  • 0

    您将click事件绑定到包含id为IconImg_CrystalReportViewer1_toptoolbar_print的打印图像的_id CrystalReportViewer1_toptoolbar_print 表 . 我认为你需要将点击绑定到图像 .

    来自事件处理程序的 Return false 将停止回发 .

    document.getElementById("IconImg_CrystalReportViewer1_toptoolbar_print").addEventListener("click", function () {
        var x = confirm("Did The Report Print properly ?");
        if (x) {
              //Do something...
    
        }
        return false;
    });
    

相关问题