• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2053
  • Last Modified:

Printing Pages/Page Break

I have an ASP web site that acts as a time tracking program used in billing clients.  On the report page, a user picks various criteria and generates a report.  The problem now is, I need the reports to be one client per page (they need to be printed).  Is there any way in Classic ASP to force a printing page break?
0
Lee W, MVP
Asked:
Lee W, MVP
  • 4
  • 4
  • 2
1 Solution
 
JohnModigCommented:
This is best done in using CSS. Add the following style to the element you are presenting your records in:

 page-break-before: always;

Example: you are gettíng the data for your report using a recordset. Then you loop thru the data and outputs the name of the client as headline (<h1>) and the info as a paragraph (<p>):

do until myRecordset.eof
 response.write "<h1 style='page-break-before: always;'>" & myRecordset("clientName") & "</h1>"
 response.write "<p>" & myRecordset("clientData") & "</p>"
loop

Ok? More info here: http://www.w3schools.com/css/css_ref_print.asp
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Sounds good - I expect to be onsite tomorrow, Thursday at the latest, and will try to implement this - if it works (and no one provides something better - which frankly, this looks pretty simple to me) - the points are yours.
0
 
JohnModigCommented:
No problem. Just let me know if you need any further advice. Remember to use your browsers preview function to see how your page would look like if you were to print it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
kevp75Commented:
page-break-after: always;

is also another method.  I use it on a datagrid that I need to be able to print.  I do an if then statement to put it in after x number of records
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Awesome - gives me a whole new respect for ASP and web based apps (I know, it's CSS, but don't burst my happy bubble).

Points to JohnModig - sorry kevp75, I appreciate the post, but ultimately, the same info you gave was available (blatently) in the link JohnModig posted.
0
 
kevp75Commented:
whatever floats your boat.

i use after, because it sets the age break after what is displayed.....before will put the page break before the display......that w3schools site is an awesome resource
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Yes, I am getting a blank page before the reports print, but I'd expect using After would do likewise only AFTER the last page prints.  So ultimately, it seems it wouldn't matter.
0
 
kevp75Commented:
it would matter actually....say you are using a table and you want each page to be only 15 rows.  you would use it on the 15th row, so the break would be after the row.......at least that's how it's supposed to work, and seems to do the trick when i've used it like that.

I simply did

if recCount = 15 then
  pgBreak = " style='page-break-after:always;'"
end if

and on my rows
<tr<%=pgBreak%>><td>Data</td></tr>

the only real problem with breaking on a row is you run a risk of messing up the table in the printed page, so what I would normally do is make a table with 1 row, then start my loop, have another table inside that that contains the data  (so esentially each recordset is it's own table)  and then in my <table> (on the inside of the row)  I put the <%=pgBreak%>

so something like this

'open recordset
response.write "<table><tr><td>"
'start the loop
response.write "<table"&pgBreak&"><tr><td>"&rs("field")&"</td></tr>"  'making each row it's own table, thus making the end of the 15th table the page break
'do the loop
response.write "</td></tr></table>"   'to close out the original row

what I see happening with page-break-before is the page break will be before the tag you inserted the style in
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
I ended up using <div> - If a report is selected that needs to cycle through itself with different criteria each time, I use <div class="pagebreak"> but if it's not using a cycle at all, I just use <div>, in both cases, closing with </div>

I admit - if it isn't obvious - CSS is NOT an area of expertise for me.
0
 
kevp75Commented:
:)
wasn't for me either, but I'm getting there.

and of course, just as CSS3 comes out too
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now