Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to print a details of a grid in table format and also it includes heading and all, help me out with solutions friends
Posted

Hi,
Try to this one:

HTML
 <script language="javascript">
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=800,height=400,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
    </script>


ASP.NET
<asp:imagebutton id="imbtnPrint" runat="server" height="35px" imageurl="~/images/icon_print.png" width="45px" onclientclick="javascript:CallPrint('divprint')" xmlns:asp="#unknown" />


HTML
<div id="divprint">
//put here gridview
</div>
 
Share this answer
 
v2
Comments
Vivek Shankar 12-Dec-11 0:10am    
hi, its showing JScript runtime error: 'CallPrint' is undefined.
Use this javascript :
XML
<script language="javascript" type="text/javascript">
        function Clickheretoprint() {

            var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
            disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";
            var content_vlue = document.getElementById('<%=dvPrintXL.ClientID %>').innerHTML;
            var docprint = window.open("", "", disp_setting);
            docprint.document.open();
            docprint.document.write('<html><head><title>Stock Statement</title>');
            docprint.document.write('</head><body><center>');
            docprint.document.write(content_vlue);
            docprint.document.write('</center></body></html>');
            docprint.print();
            docprint.document.close();
            docprint.focus();

        }
    </script>


//on .aspx page :
XML
<a href="#" onclick="javascript:Clickheretoprint();">
                                                                                            <img alt="Print" src="../Images/print.gif" style="border: none" /></a>


//on .cs page :
C#
public override void VerifyRenderingInServerForm(Control control)
    {
        // Confirms that an HtmlForm control is rendered for the
    }



Hope this will help you.
Don't forget to mark as answer if it helps. :)
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900