Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 January 5th, 2004, 12:25 PM
Registered User
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default dyanmic and not so dynamic... (page breaks)

hi, im just beginning with this asp stuff, and i must admit, it's very cool when it works. im currently making some client/address stuff for my dad's company, but get stuck with the following problem.

i have a paga with all the addresses in, like over 500 or something. but. ii i print it out the tables dont stay complete. so, i thought of adding a dynamic page break, is that possible? i mean, it's kind a silly, i have this great dynamically built page, with all addresses. but as they vary in size (some have all fields filled in, some dont), i would like to 'tell' the printer to keep the records complete. is this in any way possible?

if not, ive also thought of the solution of just printing like 3 out per page. is that possible?

very gratefull for anyone's help/advise,
thanx..


 
Old January 6th, 2004, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

see the archive
http://p2p.wrox.com/topic.asp?TOPIC_ID=620
http://p2p.wrox.com/topic.asp?TOPIC_ID=6324
 
Old January 8th, 2004, 05:47 AM
Registered User
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for these links. i have looked through them but cant help myself with a stylesheet solution. and my problem has nothing to do with a returning header.

like, my code is like this (see below) and i want to enter breaks dynamically, or if that cant be done, after 3 records. ive not yet found a similar problem/solution.

Code:
<%
DIM mySQL, objRS
mySQL = "SELECT * FROM Bedrijven ORDER BY Bedrijfsnaam" 
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorType = 1
objRS.Open mySQL, objConn, adOpenKeySet
%>

<%
DIM iRecordCount
iRecordCount = 0
DO WHILE NOT objRS.EOF
IF iRecordCount Mod 1 = 0 THEN

%>

<p><table>
 <tr>
  <td colspan="2" valign="top"><b>
<%
If objRS("PreBedrijfsnaam") <> "" Then
   Response.Write objRS("PreBedrijfsnaam") & "&nbsp"
End if
%><%=objRS("Bedrijfsnaam")%></b><br>
<%
If objRS("BedrijfsnaamOud") <> "" Then
   Response.Write "<i>" & objRS("BedrijfsnaamOud") & "<br></i>"
End if
%>
<%=objRS("CashIDklant")%> <%=objRS("CashIDleverancier")%><br>BTW nummer <%=objRS("BTWnummer")%></td>
 </tr>

 <tr>
  <td valign="top" width="300">Postbusadres</td>
  <td><%=Replace(objRS("Postbus"), vbCrLf, "<br>") %></td>
 </tr>
 <tr>
  <td valign="top">Adres</td>
  <td><%=Replace(objRS("Adres"), vbCrLf, "<br>") %></td>
 </tr>
 <tr>
  <td valign="top">Afleveradres(sen)</td>
  <td><%=Replace(objRS("Afleveradres1"), vbCrLf, "<br>") %><br><%=Replace(objRS("Afleveradres2"), vbCrLf, "<br>") %></td>
 </tr>
 <tr>
  <td valign="top">Aflever info</td>
  <td><%=Replace(objRS("AfleverInfo"), vbCrLf, "<br>") %></td>
 </tr>
 <tr>
  <td valign="top">Telefoonnummer(s)</td>
  <td><%=objRS("Telefoonnummer1")%></td>
 </tr>
<%
 If objRS("Telefoonnummer2") = "" Then
  Response.Write ""
 Else
  Response.Write ("<tr><td></td><td>")
  Response.Write objRS("Telefoonnummer2")
  Response.Write ("</td></tr>")
 End if
%>
<%
 If objRS("Telefoonnummer3") = "" Then
  Response.Write ""
 Else
  Response.Write ("<tr><td></td><td>")
  Response.Write objRS("Telefoonnummer3")
  Response.Write ("</td></tr>")
 End if
%>
<%
 If objRS("Telefoonnummer4") = "" Then
  Response.Write ""
 Else
  Response.Write ("<tr><td></td><td>")
  Response.Write objRS("Telefoonnummer4")
  Response.Write ("</td></tr>")
 End if
%>
<%
 If objRS("Telefoonnummer5") = "" Then
  Response.Write ""
 Else
  Response.Write ("<tr><td></td><td>")
  Response.Write objRS("Telefoonnummer5")
  Response.Write ("</td></tr>")
 End if
%>
<%
 If objRS("Telefoonnummer6") = "" Then
  Response.Write ""
 Else
  Response.Write ("<tr><td></td><td>")
  Response.Write objRS("Telefoonnummer6")
  Response.Write ("</td></tr>")
 End if
%>
 <tr>
  <td valign="top">Faxnummer(s)</td>
  <td><%=objRS("Faxnummer1")%></td>
 </tr>
<%
If objRS("Faxnummer2") <> "" Then
   Response.Write "<tr><td></td><td>" & objRS("Faxnummer2") & "</td></tr>"
End if
%>
<%
If objRS("Faxnummer3") <> "" Then
   Response.Write "<tr><td></td><td>" & objRS("Faxnummer3") & "</td></tr>"
End if
%>
 <tr>
  <td valign="top">Mobielnummer(s)</td>
  <td><%=objRS("Mobielnummer1")%><br><%=objRS("Mobielnummer2")%></td>
 </tr>
 <tr>
  <td valign="top">E-mailadres</td>
  <td><a href="mailto:<%=objRS("Emailadres")%>"><%=objRS("Emailadres")%></a></td>
 </tr>
 <tr>
  <td valign="top">Website</td>
  <td><a href="http://<%=objRS("Website")%>" target="blank"><%=objRS("Website")%></a></td>
 </tr>
 <tr>
  <td valign="top">Extra info</td>
  <td><%=objRS("ExtraInfo")%></td>
 </tr>
</table>


<%
END IF
iRecordCount = iRecordCount + 1
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
 
Old January 10th, 2004, 08:43 PM
Authorized User
 
Join Date: Jun 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

well i do think your solution lays in the use of a specifiek stylesheet, with the media-type "print".

Let me explain (it is something i didn't try myself yet but i think it must work.

- include a stylesheet, with media="print"
- in this stylesheet, you (only) have:

br.newpage{
page-break-before:always;
}

- if you want to add a pagebreak in your html, you put there:

<br class="newpage">

- if you want it dynamically, then you only write it after every third record ( decision with MOD 3).

- for a more precise pagebreak before the end of the page and not in a recordset, that is more sophisticated. In the print-stylesheet you can specify what type and size of font, also vertical space etc. So i think, in your asp-script you can keep track of how much vertical space there is left, every time you have written a line, and then, based on "where you are" on the page and the amount of vertical space you need to write your next record, decide if you have to write your <br class="newpage">. i think it can be done, maybe not easily.

good luck,
mndrx
 
Old January 12th, 2004, 03:12 PM
Registered User
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx mndrx, that last option is what i would like to do, but this exceeds my asp knowledge im afraid. thats why im asking others for help. it also seems to me that i cant be the only person with this 'problem'. yet i cant find a cut 'n dry answer. shame.

if indeed no one responds with the dynamic option so to speak, i will go for the 3 records per page option. u say mod 3, i do understand the result, but dont understand how to do this. can u advise me?

thanx in advance for any help here. i am learning, slowly!

 
Old January 12th, 2004, 06:34 PM
Authorized User
 
Join Date: Jun 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

a styleblock has to be in the head of your document:
<STYLE type="text/css" media="print">
<!--
br.newpage{page-break-before:always;}
-->
</STYLE>
or the style can be in a separate stylesheet too.

...

<%
DIM mySQL, objRS

[..here the rest of your page .]

</table>

<%
END IF
if iRecordCount MOD 3 = 0 then response.write "<br class=""newpage"">"
iRecordCount = iRecordCount + 1
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>


try it out, i don't know if it will work...

grtz,
mndrx
 
Old January 12th, 2004, 06:53 PM
Authorized User
 
Join Date: Jun 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

as a matter of fact you could also use a page-break-before that will affect your tables, in this way:

<STYLE type="text/css" media="print">
<!--
table {page-break-before:auto;}
-->
</STYLE>

so you don't have to caculate your MODulus.
This means that a page-break will occur before a table, not in a table.
Unfortunately, i think the "auto" isn't implemented in browsers (or is it?)
try it out yourself. The "always" is implemented in IE it seems.

bye,
mndrx
 
Old January 13th, 2004, 05:11 PM
Registered User
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi ive tried ur solution with the mod, although it sounds good, it doesnt work. i get an error. but u are right, i would like something like this. does anyone know of a working code?

 
Old January 14th, 2004, 03:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well it should work, i have not tried the exact code i have written so there is likely to be a typo or something, and here i have no access to IIS, so i can't test it.
What error do you get?
Do you use an external stylesheet (a .css) or a style-block in the head-section of your document?
In either case, don't forget to put the declaration in it (and not somewhere else in your .asp!)

br.newpage{page-break-before:always;}

Don't even bother if media is print or not, you won't see the pagebreak on the screen.

something else: if you do a response.write, don't forget to change the single " into double "" in your string (example : response.write "<br class=""newpage"">")

--------------------------------
this here is a pure html-test and this works:
--------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<HEAD>
<TITLE>test</TITLE>
<STYLE type="text/css" media="print">
<!--
p {color:red; font-size:30px}
br.newpage{page-break-before:always;}
-->
</STYLE>
</HEAD>

<BODY>
This is page 1
<br>
This is page 1
<br>
This is page 1
<p>Still page one but printed in red and bigger and in a paragraph</p>
<BR class="newpage">
This is page 2.
</BODY>
</HTML>
--------------------------------
Look at it on screen and then do a print preview.
You'll see the difference.
If not, then there must be something wrong again ;)

bye,
mndrx
 
Old January 16th, 2004, 01:07 PM
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi schaar

I'm trying to do a similar thing on my site, except I want to either allow the user to select any number of page breaks dynamically or keep a table together on a page.

I'll share what I've found out...

There's a way to add a break as mndrx describes, but with a clever twist, you can select it by using a checkbox:

In the <head></head> put:
<script>
function breakpagehere(){
if (!document.getElementById){
alert("You need IE5 or NS6 to run this example")
return
}
var thestyle=(document.forms.myform.mybox.checked)? "always" : "auto"
for (i=0; i<document.getElementsByTagName("H6").length; i++)
document.getElementsByTagName("H6")[i].style.pageBreakBefore=thestyle
}

</script>

(if it doesn't work here out it at the bottom of the page, above </html> - you can use any tag for this, not just <h6>)


In the <body> put:
<form name="myform">
<input type="checkbox" name="mybox" onClick="breakpagehere()"> Print break?
</form>
    <h6></h6>

Selecting the checkbox puts the page break in - cool :D, except it only works once using checkboxes. :(

I got this from:
http://www.javascriptkit.com/dhtmltu...agebreak.shtml

Now I'm looking for a way to do this using an array and asp, which is a bit beyond my asp skills!

If you meet any success, let me know, and of course, I'll reciprocate. Best of luck! :)







Similar Threads
Thread Thread Starter Forum Replies Last Post
Page breaks in a table aspless Classic ASP Basics 4 January 18th, 2008 01:39 PM
Page Breaks bcogney XML 10 March 29th, 2007 04:01 PM
Dyanmic Page Break in Reporting Servies kdineshbabuct BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 February 5th, 2007 04:04 AM
Page breaks rupen HTML Code Clinic 1 October 4th, 2006 04:08 PM
forcing page breaks emprise Crystal Reports 0 July 26th, 2004 03:51 AM





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