hi..
How will i use print and print preview option. I have to print only a part of a page.
for that i declare in a div and give that a id and then using java function to print that portion but my problem is that the page is directly printed and i am not getting the option of print preview.
How will it possible?Please give me suggestion
My code is as follows:
please help...
How will i use print and print preview option. I have to print only a part of a page.
for that i declare in a div and give that a id and then using java function to print that portion but my problem is that the page is directly printed and i am not getting the option of print preview.
How will it possible?Please give me suggestion
My code is as follows:
Code:
code for aspx page
<head>
<script type="text/javascript">
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script></head>
<body>
<div id="divPrint">
................
</div>.........
<asp:ImageButton ID="cmdPrint" runat="server" ImageUrl="~/Images/print.gif" OnClick="cmdPrint_Click" />
...............
</body>
and that the code i used in .aspx.cs page
protected void cmdPrint_Click(object sender, ImageClickEventArgs e)
{
string contentId = "divPrint";
string javaScript = "<script language=JavaScript>CallPrint('" + contentId + "');</" + "script>";
RegisterStartupScript("PrintWindowScript", javaScript);
}