Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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
 
Old May 17th, 2004, 02:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing in asp

How can print by the asp file that it print 30 records in each page?

when I click the print button it should be print 30 records
I use following asp coding.

 <%
ssql1="select distinct contractno from approvals"
set rs1=cn.Execute(ssql1)
do while rs1.eof=false

ssql2="SELECT employees.empno, employees.name, approvals.contractno, assignments.aposit, assignments.acontract, assignments.astrdate, assignments.aenddate FROM (employees INNER JOIN approvals ON employees.empno=approvals.empno) INNER JOIN assignments ON employees.empno=assignments.empno where approvals.contractno='" & rs1("contractno") &"' and aenddate between '"&astrdate&"' and '"&aenddate&"'"

ssql3="SELECT employees.empno, employees.name, assignto.aposit, assignto.acontract,assignto.contractno, assignto.astrdate, assignto.aenddate FROM (employees INNER JOIN assignto ON employees.empno=assignto.empno) where assignto.acontract='" & rs1("contractno") &"' and aenddate between '"&astrdate&"' and '"&aenddate&"' "

set rs2=cn.Execute(ssql2)
set rs3=cn.Execute(ssql3)

%>
<table width="740">
  <tr bgcolor="">

<%
TRIP CONTRACT NO. <%Response.Write(rs1("contractno"))%> // count second and third loop records in each contractno and print 30 records if each contractno
have more then 30 records, print remaining recors from the next new page.

<%

do while rs2.eof=false

Response.Write("<tr>")
Response.Write("<td>" & rs2("empno") & "</td>")
Response.Write("<td>" & rs2("name") & "</td>")
Response.Write("<td>" & rs2("aposit") & "</td>")
............

rs2.movenext
loop

%>

<table width=740>

<%

do while rs3.eof=false

Response.Write("<tr>")
Response.Write("<td>" & rs3("empno") & "</td>")
Response.Write("<td>" & rs3("name") & "</td>")
Response.Write("<td>" & rs3("aposit") & "</td>")
................

rs3.movenext
loop

rs1.movenext
loop

%>
</table>


<INPUT id=button1 type=button value=PRINT name=button1 onClick=print()>


I use three loop, records display like this.

contractno 2016 // first loop contractno
....................... // second loop records

contractno 2002
................. // third loop records
and so on....


how can print the 30 records in each contractno (group) , if each contractno have less then 30 records (second loop + third loop) print it and start printing
next contractno from the next page, if contractno have more then 30 records, print 30 records in one page and then remain records
print in next page.
Every new page should be print new contractno records.

when I click print button, it also print, print button, it should not be print the print button.

my data in sql server 2000, there is some problem in Access report, hence I am trying to print the records direct from ASP page.

Please help (guide) me, what coding can be use to print the
records by the above coding.

Regards.

Mateen










 
Old May 23rd, 2004, 11:58 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

javascript:window.print()

Wind is your friend
Matt
 
Old May 24th, 2004, 03:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response.

I use in print button like this

<INPUT id=button1 type=button value=PRINT name=button1 onClick="javascript:window.print()">

but it is print the print button also why ?

how can use it ?

secondly, when I click print button, it also print
next butt, previous button, and
path of file ie http://dcilweb/page.asp
current date
and page 1 of 1 also

how can do that when click print button, it should
only print the data only and not print other things ?

regards.

Mateen





Quote:
quote:Originally posted by mat41
 javascript:window.print()

Wind is your friend
Matt
 
Old May 24th, 2004, 04:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this FAQ:
http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=240

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 24th, 2004, 05:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mateen,

Thanks for your personal message. I'll answer here instead, if you don't mind.

Yes, you should create two different files with your style sheet definitions. One is your regular style sheet (one you may already be using), and the other is specifically for printing. So, just create a new text document, rename it to PrintStyle.css (or any other name you want), and add a <link> element that points to this style sheet (just like you would point to any other stylesheet).

When the page gets printed, the browser looks at the stylesheet with the media="print" attribute, sees that the definition for .NonPrintable is set to display: none and will therefore hide the elements with that class applied.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 24th, 2004, 05:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your response.

I trying this, but i could not success to print un-necessary thing
from the asp page.

where is mainstype.css and printstyle.css files ?

it will need to create these css files ?

how can get it ?

I use like this..

<html>
<head>
  <link href="/Styles/MainStyle.css" rel="stylesheet" type="text/css">
  <link href="/Styles/PrintStyle.css" rel=" stylesheet"
                                  type="text/css" media="print">
</head>
<body>

asp coding.........
....


<input type="button" value="I am hidden" style="NonPrintable">
</body>
</html>

you will like to give one example please?

regards.

Mateen



Quote:
quote:Originally posted by Imar
 Take a look at this FAQ:
http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=240

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Page Printing itHighway Classic ASP Basics 2 August 16th, 2012 03:08 PM
help for printing in ASP.NET agro_menon .NET Framework 1.x 3 August 13th, 2007 05:15 AM
printing from asp.net user1 Crystal Reports 0 January 3rd, 2005 02:50 AM
Direct Printing from ASP kbaker Classic ASP Basics 1 April 19th, 2004 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.