Adding a page break between items in a ASP.NET datalist output

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I recently wrote an ASP.NET app that used user controls. I produced a printer-friendly output form. One requirement was a pagebreak between one part of the form and another. I had no problem adding the style definition below in the <hr> tag (line tag) which was the last item in the page before the break:

<hr color="gray" size="1" style="PAGE-BREAK-AFTER: always"> and when the form is printed it forces a page-break.

However, now I'm working with a data list on another app. I need to force a page break between each item in the datalist (detailed info which takes up to close to a page). I tried something similiar and tried to add this same code to the Separator Template. It gives no errors but no page break occurs. Does anyone have any ideas, this is very important requirement. The datalist control was the greatest thing for my app so I don't want to change the way I'm displaying the data.

Barbara Alderton
 
Barbara Alderton said:
I recently wrote an ASP.NET app that used user controls. I produced a
printer-friendly output form. One requirement was a pagebreak between one
part of the form and another. I had no problem adding the style definition
below in the said:
<hr color="gray" size="1" style="PAGE-BREAK-AFTER: always"> and when the
form is printed it forces a page-break.
However, now I'm working with a data list on another app. I need to force
a page break between each item in the datalist (detailed info which takes up
to close to a page). I tried something similiar and tried to add this same
code to the Separator Template. It gives no errors but no page break
occurs. Does anyone have any ideas, this is very important requirement.
The datalist control was the greatest thing for my app so I don't want to
change the way I'm displaying the data.

Barbara, use View->Source to take a look at the HTML which is being
generated for your Separator template. It may explain why you're not getting
a page break.
 
The source looks identical to the source of the app that works.

<hr color="gray" size="1" style="PAGE-BREAK-AFTER: always">


I did find this:
The page break attributes only apply for block level elements and are not inherited.
So if you are specifying page-break-before or page-break-after with position:absolute or position:relative, then the page breaks will have no effect.

The datalist positioning was setup as absolute. I took that out and I can get the page break to work.

Barbara
 
Barbara Alderton said:
The source looks identical to the source of the app that works.

<hr color="gray" size="1" style="PAGE-BREAK-AFTER: always">


I did find this:
The page break attributes only apply for block level elements and are not inherited.
So if you are specifying page-break-before or page-break-after with
position:absolute or position:relative, then the page breaks will have no
effect.
The datalist positioning was setup as absolute. I took that out and I can get the page break to work.

Thanks for the update, Barbara, and for the info on page-break-after.
 
Back
Top