SQL Reporting Services – Print Button not shown in Mozilla

I don’t think it uses ActiveX, because in the table onclick event there is a simple:

ReportFramerpvReport.GetReportFrame().contentWindow.print()

Anyway, i replaced this print stuff with my own print function, because this code above wasn’t working on FF..

I know it’s ugly…but it works! (just replace the ControlName value with your ControlID and be sure to add jQuery lib in your page)

    $(document).ready(function()
    {
        if ($.browser.mozilla)
        {
            try
            {
                var ControlName="RptDespesas";
                var innerScript="<scr" + 'ipt type="text/javascript">document.getElementById("' + ControlName + '_print").Controller = new ReportViewerHoverButton("' + ControlName + '_print", false, "", "", "", "#ECE9D8", "#DDEEF7", "#99BBE2", "1px #ECE9D8 Solid", "1px #336699 Solid", "1px #336699 Solid");</scr' + 'ipt>';
                var innerTbody = '<tbody><tr><td><input type="image" style="border-width: 0px; padding: 2px; height: 16px; width: 16px;" alt="Print" src="https://stackoverflow.com/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=9.0.30729.1&amp;Name=Microsoft.Reporting.WebForms.Icons.Print.gif" title="Print"></td></tr></tbody>';
                var innerTable="<table title="Print" onmouseout="this.Controller.OnNormal();" onmouseover="this.Controller.OnHover();" onclick="PrintFunc(\"' + ControlName + '\'); return false;" id="' + ControlName + '_print" style="border: 1px solid rgb(236, 233, 216); background-color: rgb(236, 233, 216); cursor: default;">' + innerScript + innerTbody + '</table>'
                var outerScript="<scr" + 'ipt type="text/javascript">document.getElementById("' + ControlName + '_print").Controller.OnNormal();</scr' + 'ipt>';
                var outerDiv = '<div style="display: inline; font-size: 8pt; height: 30px;" class=" "><table cellspacing="0" cellpadding="0" style="display: inline;"><tbody><tr><td height="28px">' + innerTable + outerScript + '</td></tr></tbody></table></div>';

                $("#" + ControlName + " > div > div").append(outerDiv);

            }
            catch (e) { alert(e); }
        }
    });

    function PrintFunc(ControlName)
    {
        setTimeout('ReportFrame' + ControlName + '.print();', 100);
    }

Leave a Comment