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 April 4th, 2005, 09:44 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default page break in asp

Hi all ,

i need to generate a report . i have to show the details of Routes , in separate sheet (page). i.e. for each rpute there should be separate page at the time of printing .

i have seen the solution in this forum , how ti insert a page break in

asp page , but in my case it is not working ,

Please help me ...

the code of the asp file is pasted below -----------

------------------------------------------------------------




<html>
<head>
</style>
<% 'H3 { pagebreak-after:always }%>
</style>
</head>
<body>
<%

startdate=request("fm")
enddate=request("to")


if startdate="" and enddate = "" then
    response.redirect("viewroutes.asp")
end if

startdate=cdate(startdate)
enddate=cdate(enddate)
edate=enddate+1

sql="Select * from routes where [start] >= '" & startdate & "'and [end] <='" & edate & "'"

set rsroutes=con.execute(SQL)
if not (rsroutes.eof and rsroutes.bof) then
    'print report header
    response.write("<table width=95% align='center' border=0>")
    response.write("<tr align='left'><td><img src='logo.gif'></td>")
    response.write("<td align='center'><b>Transport Routes from ")
    varm=monthname(month(startdate),true)
    vard=day(startdate)
    vary=year(startdate)
    response.write(varm & "&nbsp;" & vard & ", " & vary & " To ")
    varm=monthname(month(enddate),true)
    vard=day(enddate)
    vary=year(enddate)
    response.write(varm & "&nbsp;" & vard & ", " & vary & "</b></td>")
    'response.write(startdate & " To " & enddate & "</b></td>")
    response.write("<td align='right'>Printed on<br>" & formatdatetime(now(),vblongdate) & " " & formatdatetime(now(),vbshorttime) & "</td></tr></table>")

    'response.write("<table width=100% border=0>")
    rsroutes.movefirst
    do while not rsroutes.eof
        response.write("<table width=100% border=0>")
        var1=rsroutes("start")
        varm=monthname(month(var1),true)
        vard=day(var1)
        vary=year(var1)
        vardt=varm & " " & vard & ", " & vary
        vartime=formatdatetime(var1,vbshorttime)

        var2=rsroutes("end")
        varm=monthname(month(var2),true)
        vard=day(var2)
        vary=year(var2)
        vardt1=varm & " " & vard & ", " & vary
        vartime1=formatdatetime(var2,vbshorttime)

        starttime=vartime
        endtime=vartime1


        response.write("<tr><td colspan=7></td></tr>")
        response.write("<tr><td colspan=3><b>RouteID : " & rsroutes("routeid") & "</b></td>")
        'response.write("<td>&nbsp;</td>")
        response.write("<td>Vehicle ID : " & rsroutes("vehicleid") & "</td>")
        response.write("<td> Driver ID : " & rsroutes("driverid") & "</td>")
        response.write("<td><b>" & trim(rsroutes("remark")) & "</b></td></tr>")

        response.write("<tr><td>&nbsp;</td>")
        response.write("<td colspan=6>")
        response.write("Total Distance :" & formatnumber(rsroutes("totaldist"),3) & " Kms&nbsp;&nbsp;&nbsp;&nbsp;")
        response.write("Total Time :" & formatnumber(rsroutes("totalhours"),2) & " Hrs.&nbsp;&nbsp;&nbsp;&nbsp;")
        response.write("Start Time :" & vardt & " " & vartime & "&nbsp;&nbsp;&nbsp;&nbsp;")
        response.write("End Time :" & vardt1 & " " & vartime1 & "</td></tr>")
        'response.write("<tr><td colspan=7></td></tr>")

        routeid=rsroutes("routeid")

        sql="select * from routedet where routeid='" & routeid & "' order by stopnumber"
        set rsdet=con.execute(SQL)
        response.write("</table>")
        if not (rsdet.eof and rsdet.bof) then
            rsdet.movefirst

            response.write("<table width=100% border=0>")
            ' print header
            response.write("<tr><td colspan=13></td></tr>")
            response.write("<tr><td width=2% align='center'><b>S. No</b></td>")
            response.write("<td width=4% align='center'><b>Emp Id</b></td>")
            response.write("<td width=17% align='center'><b>Emp Name</b></td>")
            response.write("<td width=4% align='center'><b>Type</b></td>")
            response.write("<td width=12% align='center'><b>Process</b></td>")
            response.write("<td width=4% align='center'><b>Shift</b></td>")
            response.write("<td width=18% align='center'><b>Address</b></td>")
            response.write("<td width=18% align='center' ><b>Pick / Drop Point</b></td>")
            'response.write("<td width=5% align='center'><b>Phone</b></td>")
            response.write("<td width=4% align='center'><b>Scheduled Time</b></td>")
            response.write("<td width=4% align='center'><b>Actual Time</b></td>")
            response.write("<td width=4% align='center'><b>Kms.</b></td>")
            response.write("<td width=5% align='center'><b>Remarks</b></td>")
            response.write("<td width=4% align='center'><b>Sign.</b></td></tr>")
            response.write("<tr><td colspan=13></td></tr>")

            response.write("<td width=2% >0</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=17% >CSPL</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=12% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=18% >&nbsp;</td>")
            response.write("<td width=18% >&nbsp;</td>")
            'response.write("<td width=5% >&nbsp;</td>")
            response.write("<td width=4% >" & starttime & "</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=5% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td></tr>")
            response.write("<tr><td colspan=13></td></tr>")

            do while not rsdet.eof
                response.write("<td width=2% >" & rsdet("stopnumber") & "</td>")
                response.write("<td width=4% >" & rsdet("empid") & "</td>")

                empid=trim(rsdet("empid"))
                empname=""
                empaddr=""
                sql="select * from employee where employeeid='" & empid & "'"
                set rsemp=con.execute(SQL)
                if not (rsemp.bof and rsemp.eof) then
                    empname=trim(rsemp("firstname")) & " " & trim(rsemp("lastname"))
                    empaddr=trim(rsemp("address1"))
                    empaddr = empaddr & "&nbsp;" & trim(rsemp("address2"))
                    empaddr = empaddr & "&nbsp;" & trim(rsemp("address3"))
                    empaddr = empaddr & "&nbsp; " & trim(rsemp("city"))
                    empaddr = empaddr & "<br><b>Phone:&nbsp;" & trim(rsdet("phone")) & "</b>"
                    empprocess=trim(rsemp("team"))
                end if

                daction=""
                if rsdet("action")="P" then
                    daction="Pick"
                end if
                if rsdet("action")="D" then
                    daction="Drop"
                end if


                response.write("<td width=17% >" & empname & "</td>")
                response.write("<td width=4% >" & daction & "</td>")
                response.write("<td width=12% align='center' >" & empprocess & "</td>")
                response.write("<td width=4% >" & rsdet("shift") & "</td>")


                response.write("<td width=18% >" & empaddr & "</td>")
                shifttime=rsdet("shift")
                home_fg=0

                if isnumeric(shifttime) then
                    shifttime=cdbl(shifttime)
                    if shifttime >= 1900 then
                        home_fg=1
                    end if
                    if shifttime <= 700 then
                        home_fg=1
                    end if
                end if


                if home_fg=0 then
                    response.write("<td width=18% >" & rsdet("landmark") & "</td>")

                else
                    response.write("<td width=18% align='center'>Home</td>")
                end if
                'response.write("<td width=5% >" & rsdet("phone") & "</td>")
                var1=rsdet("eta")
                varmonth=monthname(month(var1))
                vard=day(var1)
                vary=year(var1)
                vartime=formatdatetime(rsdet("eta"),vbshorttime)
                response.write("<td width=4% >" & vartime & "</td>")



                'response.write("<td width=4% >Scheduled Time</td>")
                response.write("<td width=4% >&nbsp;</td>")
                response.write("<td width=4% >&nbsp;</td>")
                response.write("<td width=5% >&nbsp;</td>")
                response.write("<td width=4% >&nbsp;</td></tr>")

                response.write("<tr><td colspan=13></td></tr>")
                laststop=rsdet("stopnumber")

                rsdet.movenext


            loop

            laststop=laststop+1
            response.write("<td width=2% >")
            response.write(laststop)
            response.write("</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=17% >CSPL</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=12% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=18% >&nbsp;</td>")
            response.write("<td width=18% >&nbsp;</td>")
            'response.write("<td width=5% >&nbsp;</td>")
            response.write("<td width=4% >" & endtime & "</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td>")
            response.write("<td width=5% >&nbsp;</td>")
            response.write("<td width=4% >&nbsp;</td></tr>")
            response.write("<tr><td colspan=13></td></tr>")


        end if
        response.write("</table>")
        rsroutes.movenext
        'Response.Write("<div style="page-break-after:always"></div>")
        'Response.Write("<style>")
        ''Response.Write("h3 { page-break-before-always}")
        'Response.Write("</style>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'Response.Write("<br class='break'>")
        'response.Write("<br class='break'>")
        'Response.Write("<H3> </H3>")

        If sLastType = "" Then
response.write ("<tr>")
sLastType = Rslist("FaultType")
ElseIf sLastType <> Rslist("FaultType") then
response.write ("<tr style=""page-break-before: always;"">")
sLastType = Rslist("FaultType")
Else
response.write ("<tr>")
End if



    loop


    response.write("</table>")

end if


%>
</body>
</html>


Rgds
 Rajiv

 
Old April 4th, 2005, 11:38 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

Lots of code to look at, I stopped here:
</style>
<% 'H3 { pagebreak-after:always }%>
</style>

You should have something like:
<STYLE type="text/css" media="print">
<!--
br.newpage{page-break-before:always;}
-->
</STYLE>
You can not start a style block with </style> Anyhow this post will do it for you:


http://p2p.wrox.com/topic.asp?TOPIC_ID=8224

Wind is your friend
Matt
 
Old April 5th, 2005, 01:01 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt,

thanx for help. but it is not working , there is no any effect of tyhis code on output, it is still in continuous way , i.e. without page brak , either i m using it , by wrong way , or there is some problem with this code . can you please write a sample programe tha will explain how to use page brak .

Rgds

Rajiv

 
Old April 5th, 2005, 01:18 AM
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

As mndrx illustrated in his post - it does work. Cut n paste this into a .html doc, browse it and do a print preview - better still print it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>test</TITLE>
<STYLE type="text/css" media="print">
<!--
br.newpage{page-break-before:always;}
-->
</STYLE>
</HEAD>
<BODY>
This text will print on page 1
<BR class="newpage">
This text will print on page 2
<BR class="newpage">
This text will print on page 3
<BR class="newpage">
This text will print on page 4.
</BODY>
</HTML>

Wind is your friend
Matt
 
Old April 5th, 2005, 01:38 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok dear , i m trying to imlement it ,

thanx

 
Old April 5th, 2005, 01:46 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANX A TON DEAR ,

IT IS WORKING ,

THANX

RGDS
RAJIV

 
Old April 5th, 2005, 01:53 AM
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

Glad to help

Wind is your friend
Matt
 
Old April 5th, 2005, 02:36 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI MATT,

CAN YOU SUGGEST ME ANY GOOD BOOK TO GO TO DEPTH OF ASP .
OR IF YOU HAVE ANY e-BOOK .

RGDS
RAJIV

 
Old April 5th, 2005, 06:29 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

Im not a fan of e-books myself. Of course Wrox have alot of good books - I started with Beginning ASP. What I do rely on heavily is .chm files and this forum. There is not much you can do with ASP that is not covered somewhere here, make friends with the search facility. Perhaps more importantly make an effort to help others where you can - then the pro's will be more inclined to spend time on your posts.

IMO - from what I am seeing in the job market here .net is calling fairly loud. I can not speak for places outside aussie, there is alot of demand for it here, I suspect I will be learning it very soon and suggest a good thing to pick up.

Didnt mean to be so verbose, I hope I have answerd your question.

Wind is your friend
Matt
 
Old April 6th, 2005, 01:21 AM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANX DEAR FOR YOUR GREAT SUGGESTION , I WILL TRY TO IMPLEMENT YOUR
SUGGESTIONS .

IM ALSO TRANSFERRING TO .NET , I KNOW THE BASICS OF ASP.NET,ADO.NET .

IN INDIA , THERE IS ALSO A LOOF DEMAND FOR .NET DEVELOPER , AND IT IS INCREASING RAPIDALLY ,

I M AGREE WITH YOUR SUGGESTION , THAT BY JOINING,AND ACTIVE PARTICIPATION IN FORUMS , I CAN LEARN MORE . I WILL TRY TO BE A ACTIVE PARTICIPENT OF THESE FORUMS.

I HAVE SOME EBOOKS OF VB.NET AND ASP , IF YOU NEED YOU CAN REPLY ME .

THANX DEAR

RGDS
RAJIV :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Break chakravarthy_vr Reporting Services 1 June 22nd, 2006 10:16 AM
ASP: page break programmatically u813222 Classic ASP Professional 5 March 28th, 2006 01:23 AM
page break in asp.net kngs Crystal Reports 0 January 30th, 2005 01:20 AM
Page Break aspadda Excel VBA 0 February 9th, 2004 02:36 PM





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