Following is the code for printing Div ,HTML or Table to printer using C# in Asp.net
<script type="text/javascript"
language="javascript">
function
print()
{
var
printFriendly = document.getElementById("div1")
var
printWin = window.open("about:blank","Voucher","menubar=no;status=no;toolbar=no;");
printWin.document.write("<html><head><title>Voucher
Report</title></head><body><h1>Agent Wise
Report</h1>" + printFriendly.innerHTML + "</body></html>");
printWin.document.close();
printWin.window.print();
printWin.close();
}
</script>
add this script lines in your header section of given page.
<div id="div1">
<table width="100%">
<tr>
<td align="center" width="225px" >
<img height="30px"
src='<%#Eval("logoimage")%>'width="100px" /><br />
</td>
</tr>
</table>
</div>
this is div that is going to print.Mainly the id of div tag is "div1".
<asp:Button ID="btnPrint"
runat="server"
Text="Print"
OnClick="btnPrint_Click"
/>
on button click event put the following code to handle print task.
btnPrint.Attributes.Add("onClick",
"print();");
That's final code.
Finding Jobs In Agra go to http://jobsinagra.wordpress.com/
ReplyDeleteAnd Get Information About Agra www.agraportal.com
A very good and informative article indeed. It helps me a lot to enhance my knowledge, I really like the way the writer presented his views.
ReplyDeleteMoneycontrol