Link to home
Start Free TrialLog in
Avatar of jrmcintosh
jrmcintosh

asked on

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

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.
Avatar of strickdd
strickdd
Flag of United States of America image

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);
Avatar of jrmcintosh
jrmcintosh

ASKER

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)



Do you want page-break while the page get printed?
Make sure the style media is set to print.
Make sure the HTML tags closed properly.
Still haven't gotten it to work in IE.
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>")
nope. i guess it's just not meant to work for me. I need to try something else.
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?
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
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial