Introduction:
Here you have find the code to print a whole web page using
html button. To print a page we use window. Print JavaScript .But its having a
drawback print with button control, this button control we don’t like button
come on the printing page, so we have to avoid the button printing using CSS.
.
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hide print button</title>
<style type="text/css" media="screen">
.PrintButton{
display:block;
}
</style>
<style type="text/css" media="print">
.PrintButton{
display:none;
}
</style>
</head>
<body>
<form id="PrintForm" runat ="server">
<h1>
print a page
with button hide</h1>
<br />
<div>
<img src="images/k4.jpg" height ="100" width="100" />
</div>
<input id="btnPrint" type="button" value="Print" class="PrintButton" onclick="window.print();" />
</form>
</body>
</html>
|
Suppose if you want to close the window automatically after
taking print out then add the below script in your page. It will close the page
after taking printout
<script type="text/javascript">
function revertback()
{
window.close();
}
window.onafterprint = revertback
</script>
|
Conclusion:
Here you seen to take print out the asp.net page and learn
to close a page after took print out.
I hope you like this article post your comments..
0 comments:
Post a Comment