1

In a specific screen I need to let the user print out some data. Due to the complexity of the data displayed, it is used a label:

lblTree.Text = stringHTML;

The tree is displayed using a dynamically constructed HTML string. The final string is 52 000 characters long. I don't think that is important, but I thought I would explain the background. In aspx, it looks like this:

<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="3" align="left" class="PrintTBLHeader"><br />report as of 20/09/2012 : <br /><br /></td>
    </tr>
    <tr>
        <td colspan="3"><br /><asp:Label runat="server" ID="lblTree"></asp:Label><br /><br /></td>
    </tr>
    <tr>
        <td colspan="3" align="left" class="PrintTBLHeader"><br />2nd title:<br /><br /></td>
    </tr>
    <tr>
        <td colspan="3"><br /><asp:Label runat="server" ID="lblMPMtree"></asp:Label></td>
    </tr>
</table>

The problem is this: when I open the print preview, it should say 6 pages (like in firefox and chrome - those are working right), but this print preview from IE8 is showing me only 3 pages.

lblTree is cut at the end of the 1st page Then on the second page, instead of showing the rest of lblTree, it starts with the "2nd title" (tr #3 in the example above)

I found some article related to something like this, where the solution was adding media="print" to the <link>.

<link rel="stylesheet" type="text/css" href="..." media="print" />

That did not work.

Henrik Ammer
  • 1,889
  • 13
  • 26
Ash
  • 1,269
  • 3
  • 25
  • 49
  • What CSS do have you applied to both the ``s aswell as the content you insert into the column that doesn't work in IE? – Henrik Ammer Sep 20 '12 at 15:32
  • the doesn't have any (as you can see in my example above), because the label is getting HTML text, fully formatted with a ton of css classes. The final TREE that is printed, has lots of colors, even small icons, stuff like that – Ash Sep 21 '12 at 10:24
  • Do you have a [doctype](http://www.w3.org/QA/2002/04/valid-dtd-list.html) declared on the page? – Henrik Ammer Sep 21 '12 at 10:43
  • Trying to make sure that IE8 hasn't gone into quirksmode, since it almost "feels" like it. Check the following SO answer how you can test if you are compatible mode or in quirkshell, http://stackoverflow.com/a/627198/600101. – Henrik Ammer Sep 21 '12 at 15:07
  • The alert is showing: BackCompat. Does that help? – Ash Sep 24 '12 at 10:44
  • 1
    Yes but it's a bad thing. It means it is in quirksmode (meaning in this case, you are defining a DOCTYPE but not keeping your code true to it). Run the page through the http://validator.w3.org and fix all mayor errors. When that is done, do the alert again and see if it comes out `CSS1Compat` or `CSS2Compat`. Until then, nothing can make certain IE8 does anything as it should. – Henrik Ammer Sep 24 '12 at 13:33
  • @HenrikAmmer I started to clean it up, I got 634 errors in the beginning. I made it down to 5 with validator.w3.org ... it worked. I don't know which one was the change that actually helped, but it worked. The Print preview now shows 6 pages instead of 3 ... Great. thank you. If you post an answer to this question, I will accept it. If you want the points ! Let me know. Thanks again – Ash Sep 25 '12 at 12:26

1 Answers1

1

To summarize:

  • Check the code if it's invalid to the DOCTYPE with the validator
  • If invalid, IE will render in quirksmode which is never a good thing.
Henrik Ammer
  • 1,889
  • 13
  • 26