We help IT Professionals succeed at work.

does css within response.write work, dealing with page break issue

jrmcintosh
jrmcintosh asked
on
624 Views
Last Modified: 2010-05-18
I have a page in asp.net (vb) that creates a sort of mail merge. I'm creating these letters with Response.Write lines in my code.

At the end of each letter I have the line:
Response.Write("<div style=""PAGE-BREAK-AFTER:always""></div>")

However this does not break my pages. Am I doing something wrong?

Thanks.
Comment
Watch Question

Commented:
Try adding a literal where you want the break like so:

Literal lit = new Literal();
lit.Value = "<div style=""PAGE-BREAK-AFTER:always""></div>";

this.Controls.Add(lit);

Author

Commented:
It still is not forcing a page break. I'm using VB.Net and added this.

Dim lit As New Literal
lit.Text = "<div style=""PAGE-BREAK-AFTER:always""></div>"
Controls.Add(lit)



Commented:
Do you want page-break while the page get printed?
Jason MintonEpic ODBA

Commented:
Make sure the style media is set to print.

Commented:
Make sure the HTML tags closed properly.

Author

Commented:
Still haven't gotten it to work in IE.
Jason MintonEpic ODBA

Commented:
Try all lower-case and make sure all of those quotes are messing you up.  Try using single quotes on the inside like below:

Response.Write("<div style='page-break-after: always;'></div>")

Author

Commented:
nope. i guess it's just not meant to work for me. I need to try something else.

Author

Commented:
I am able to create a page break with this:

Dim breaker As New HtmlGenericControl("br")
breaker.Attributes.Add("style", "page-break-after:always;")
Controls.Add(breaker)

I'm using response.write's for the mail merge letter. How do I plop this break between each letter?

Author

Commented:
I figured this out and did the following:

Changed from Response.Write to a Stringbuilder. Created the letter, and added it to a label, then did this:

            Dim lab As New Label
            Dim breaker As New HtmlGenericControl("br")

            lab.Text = letter.ToString()
            lab.ID = "lab_" & i.ToString()
            breaker.ID = "br_" & i.ToString()
            breaker.Attributes.Add("style", "page-break-after:always;")

            Controls.Add(lab)
            Controls.Add(breaker)
            letter = New StringBuilder

THIS QUESTION CAN BE CLOSED
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.