Saturday, November 25, 2006

Print web page: Hide content

I discovered some kind of a bug in ASP.NET 2.0...

First things first. On my "web coloring page" are some Google ads. I don't want to show these ads on the prints.

Start with some css at in the <head> tag of the web page:

<style type="text/css" media="print">
  .donotprint{Display : none}
  .doprint{Display: normal}
</style>


Then create a table. For each <td> you choose the between the classes doprint and .donotprint.

I have tried this with <div> tags, but that did not work; All content after using the .donotprint class was invisible, even after using the .d.oprint class with the next <div> tag. Very strange...

But it works with tables.

No comments: