3/19/2015

How to print asp.net panel contents using javascript

How to print asp.net panel contents using javascript



In this article explained how to print the contents of ASP.Net Panel control using JavaScript.
< html xmlns="http://www.w3.org/1999/xhtml">
< head>
< title>< /title >
        < script type = "text/javascript">
        function PrintPanel() {
        var panel = document.getElementById("ctl00_ContentPlaceHolder1_Panel1<%=Panel1.ClientID %>");
        var printWindow = window.open('', '', 'height=400,width=800');
        printWindow.document.write('');
        printWindow.document.write('');
        printWindow.document.write(panel.innerHTML);
        printWindow.document.write('');
        printWindow.document.close();
        setTimeout(function () {
                                                printWindow.print();
                                            }, 500);
        return false;
        }
        < /script>
< /head>
< body>
        < form id="form1" >
        < asp : Panel id="Panel1" >
                < span style="font-size: 10pt; font-weight:bold; font-family: Arial">HI ,
                    This is < span style="color: #18B5F0">EasyWay Programming. < /span>
                    EasywayProgramming.com
                    easywayprogramming.blogspot.in < /span>
        < /asp:Panel>

        < asp:Button ID="btnPrint" Text="Print" OnClientClick = "return PrintPanel();" />
        < /form>
< /body>
< /html>

In the above HTML Markup has an ASP.Net Panel control Panel1 whose contents needs to be printed and an ASP.Net Button btnPrint which has an OnClientClick event which will call the JavaScript method PrintPanel() to print the contents of the Panel

4 comments:

  1. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    digital marketing training in marathahalli

    digital marketing training in rajajinagar

    Digital Marketing online training

    full stack developer training in pune

    full stack developer training in annanagar

    ReplyDelete
  2. Very nice blogs!!! i have to learning for lot of information for this sites…Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

    Digital Marketing Training in Chennai

    Digital Marketing Course in Chennai

    ReplyDelete