 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 21st, 2003, 02:43 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Printing problem in asp
Hello Sir
I am developing on e super market application using ASP 3.0,Javascript and IIS 5.0
I want to print the bills on 6"X6" size using Epson LX-300+ printer. But I am unable to see custome paper size option in page setup dialog box. So that I am unable to set paper size even though I changed default settings of printer .
Is this possible in ASP or in Javascript to specify paper size?
And also I have another query that when I calls up "window.print()"
code , that print dialoge box populates. I wanted to avoid that population of dialog box. window contents should get printed directly .Is this possible ?
with regards
Umesh S. Deole
Creative innovation
Pune
India
Umesh S. Deole
Creative Innovation
|
|

November 21st, 2003, 05:28 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
AFAIK, you won't be able to change the paper size from within JavaScript, although there may be some specific IE settings for this (never tried, so I really don't know).
It *is* possible to have your page printed automatically, without the dialog. It's a bit tricky, it works on IE only and you may need to lower your security settings, but it does work. Copy and paste the following code to a new HTML document, run it in your browser and hit the print button. The page gets printed on the default printer without a confirmation dialog.
Code:
<html>
<head>
<script language="JavaScript">
DA = (document.all) ? 1 : 0
function HandleError()
{
alert("\nNothing was printed. \n\nIf you do want to print this page, then\nclick on the printer icon in the toolbar above.")
return true;
}
</script>
</head>
<body>
<form>
<input type="button" value="Print Page" onClick="window.print();">
</form>
<script language="VBScript">
Sub window_onunload()
On Error Resume Next
Set WB = nothing
On Error Goto 0
End Sub
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
On Error Resume Next
If DA Then
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
Else
call WB.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","","")
End If
If Err.Number <> 0 Then
If DA Then
Alert("Nothing Printed :" & err.number & " : " & err.description)
Else
HandleError()
End if
End If
On Error Goto 0
End Sub
If DA Then
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
Else
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
End If
document.write "<object ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:"
document.write wbvers & """> </object>"
</script>
</body>
</html>
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 2nd, 2004, 10:17 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, this is really excellent!!! This is exactly what i was looking for. I am wondering if you can print specific frame instead of printing the whole page using this code!
Thanks
|
|

November 3rd, 2004, 03:46 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
I haven't tried it, but it might work. The code can be called from a framed page, and not from the frameset.
Have you tried it out??
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 5th, 2004, 03:47 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi amd99,
Thanks for your personal message; can you post the code for your page here? I had trouble reading it in my e-mail program.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 14th, 2004, 06:52 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar, here is my code. There are two print buttons. The one that prints direct to default printer is not working. I would like that button to print the Inline Frame instead of whole page.
Thanks for your help
<head>
<script language="JavaScript">
DA = (document.all) ? 1 : 0
function HandleError()
{
alert("\nNothing was printed. \n\nIf you do want to print this page, then\nclick on the printer icon in the toolbar above.")
return true;
}
</script>
</head>
<html>
<body>
<form>
<input type="button" value="PrintFrame(works)" onclick="document.getElementById('I1').contentWind ow.focus();document.getElementById('I1').contentWi ndow.print();return false;">
<input type="button" value="PrintFrame(not working)" onClick="window.print();">
</form>
<script language="VBScript">
Sub window_onunload()
On Error Resume Next
Set WB = nothing
On Error Goto 0
End Sub
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
On Error Resume Next
If DA Then
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
Else
call WB.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","","")
End If
If Err.Number <> 0 Then
If DA Then
Alert("Nothing Printed :" & err.number & " : " & err.description)
Else
HandleError()
End if
End If
On Error Goto 0
End Sub
If DA Then
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
Else
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
End If
document.write "<object ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:"
document.write wbvers & """> </object>"
</script><p>
<a href="text/z_printtest.htm">
<iframe name="I1" src="text/z_printtest.htm" width="590" height="282">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe></a></p>
</body>
</html>
|
|

November 15th, 2004, 03:23 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I am not sure I understand this correctly. You say you want to print the iframe, yet the button that prints the iframe has (Works) on its value.
Now which button works, and which one doesn't?
If I were you, I'd move all the script specific stuff to the page in the iframe, and wrap it in a single method.
Then the outer page simply calls the method of the inner page, to print it.
I am not exactly sure about the inner workings of this code, but I suspect that the code and the wbvers object should be on the page you want to print....
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Conditionnel Humain (Prothese) by Front 242 (Track 2 from the album: Geography 2) What's This?
|
|

November 16th, 2004, 11:48 AM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar, many many thanks!!
"If I were you, I'd move all the script specific stuff to the page in the iframe, and wrap it in a single method."
It worked!
Thanks again,
|
|

August 1st, 2005, 01:26 PM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I need to do this, can I see the final code? What did you do in the frame and how do you call it?
|
|

August 1st, 2005, 01:42 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Did you already try some of the code presented in this thread?
You should move the code to the framed page, and then create a method in it like PrintDocument that fires the Print method.
That from your containing page, call that PrintDocument method....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Johnny, Kick A Hole In The Sky by Red Hot Chili Peppers (Track 13 from the album: Mother's Milk) What's This?
|
|
 |