473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

print the contents of a div

I have the following code on my ASPX (ASP 2.0) page:

<head runat="server">
<meta content="text/VBScript" http-equiv="content-script-type" />
<title>Call duty</title>
<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>
</head>

and between the form tags:

<asp:Button ID="btPrint" runat="server" Style="left: 1508px; position:
absolute; top: 92px" Text="Click this button to print the form!"
OnClientClick="javascript:callprint('divprint')" Visible="False" />
<div id="divPrint" runat="server" style="left: 1500px; width: 715px;
position: absolute; top: 128px; height: 1200px" visible="false">
<asp:Image ID="imPrint" runat="server" Height="100%" Width="100%"
style="left: 12px; top: 4px" /></div>
The idea is that when the user clicks on the button, the contents of the DIV
is printed, nut it doesn't work.
What am I doing wrong?

Please help!

rg,
Eric
Jan 1 '06 #1
4 1824
You probably need to open the document itself for writing:

WinPrint.document.open();

before the line to write in the HTML...

Jan 1 '06 #2
thanks, but that is not the solution.

any other suggestions that can help?

rg,
Eric

"Paul Henderson" <pa***********@pittville.demon.co.uk> schreef in bericht
news:11**********************@o13g2000cwo.googlegr oups.com...
You probably need to open the document itself for writing:

WinPrint.document.open();

before the line to write in the HTML...

Jan 1 '06 #3
> any other suggestions that can help?

It works for me if:
a) I add the line mentioned above
b) I change "javascript:callprint('divprint')" to
"javascript:CallPrint('divPrint')"
c) I make the button visible :-)

Jan 1 '06 #4
Thanks again, now I know what the problem was.
I didn't know it was all case-sensitive (line b)

now it works.

rg,
Eric
"Paul Henderson" <pa***********@pittville.demon.co.uk> schreef in bericht
news:11**********************@z14g2000cwz.googlegr oups.com...
any other suggestions that can help?


It works for me if:
a) I add the line mentioned above
b) I change "javascript:callprint('divprint')" to
"javascript:CallPrint('divPrint')"
c) I make the button visible :-)

Jan 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: me | last post by:
Hey all, well i am also a newbie :) i saw this on many sites: <img src="somephp.php?blabla" width="100"> how can i make that to? i want to reffer to a php file that returns or prints a jpg...
1
by: yawnmoth | last post by:
say i have a zip file - test.zip - with a file - somefile.txt - in it, whose contents are as follows: this is a test when i try running the following script on the above zip file, i get...
2
by: Sharon | last post by:
Hi All. Is there a way to print the content of DataGridView, Without using Graphics.DrawString on every row? Thanks, Sharon.
0
by: Paco Ferre | last post by:
Hello, I founded some examples of WebControl printing in internet and tryed to have them working for a DataGrid, something not very complicated. I have a page, Page1.aspx with a DataGrid...
2
by: PJO | last post by:
I've got a Print menu item on a parent navigation form. How can I get it to print the contents of a RichTextBox located on a child form? TIA -Pat
2
by: Christie | last post by:
In my application, lines (shapes such as circles) and text are drawn in a picturebox. I am struggling to find a way to print the text and shapes. There is no images in the picturebox. Could...
0
by: SMSRKU | last post by:
I have a win forms application (c#) that has a UserControl containing many labels and text boxes. I want to select the labels and textboxes from that UserControl and print only the selected items...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
4
sagark
by: sagark | last post by:
Hello All, Need Help. I have some contents in System.io.memorystrean object. I want to prite these contents on to page with something like response.write(..) but I am unable to print the...
6
by: samvb | last post by:
Hi, I was asked by my department to print contents of a frame control. The program was designed by another person and now, i am asked to add this specific task. I dont have proper documentation of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.