Wednesday, May 07, 2025

Breaking News
>> Securing and encrypt View State and Cookies values  >> Page has one or more controls that do not correspond with   >> “The Controls collection cannot be modified because the control contains code blocks”  >> How to fix "Validation(): Element 'xxxx' is not supported  >> How to create a new session in ASP.NET programmatically  >> MySQL Database Backup using mysqldump command    

Editors Picks

Thursday, January 19, 2012

print div control using javascript


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function PrintDiv()
{
var divToPrint = document.getElementById('divToPrint');
var popupWin = window.open('', '_blank', 'width=300,height=300');
popupWin.document.open();
popupWin.document.write('' + divToPrint.innerHTML + '');
popupWin.document.close();
}
script>
head>
<body >
<div id="divToPrint" >
<div style="width:200px;height:300px;background-color:teal;">
      Sunil gurjar harda
div>
div>
<div>
<input type="button" value="print" onclick="PrintDiv();" />
div>
body>
html>

1 comment :

  1. You forgot the part that does the actual print

    ReplyDelete

Contact Us

Name

Email *

Message *