Can I print a portion of a page?

J

John Kotuby

Hi all,
Again running into problems converting existing ASP to ASP.NET 2 in VB. I am
simply trying to print a portion of the HTML displayed on-screen and not the
entire document. Specifically I just want to print the HTML contained in the
content area of my Masterpage layout, without the user having to click
File/Print in the browser.

I was able to create an Email body from that same content using some
javascript and and the OuterHTML property of the container (which in this
case is a Table with a specific Id). Of course I added the surrounding
<html> and <body> tags before sending the email. Worked just fine.

The ASP program uses frames for printing. One frame allows the user to
select some options which change the printed output in some minor ways. The
2nd frame contains the HTML page content without the Menus, borders, etc.
The first frame also contains a Print button that calls the javascript
code...

<script>
function printIT()
{
window.parent.frames[1].focus()
window.parent.frames[1].print()
}
</script>

Pretty simple stuff really. I've been searching most of the day for a good
article on using frames in .NET and finally found one. The article suggested
placing the frameset in a plain .htm page and then calling the .aspx pages
as the source.

So I create my HTM page and now VS2005 is giving me the error -- Element
"frameset" is not supported. The author clearly states that his method was
used in .NET 2.0. Very frustrating indeed.

Sometimes finding relevant content in MSDN is like locating a needle in a
haystack. It seems like this should be a rather easy task.

So my questions:
1. Can I use frames in such a way as to allow VS to actually accept and
compile the syntax?
2. Does ASP.NET have an easier way to accomplish what I need to do?

Thanks to all for your input.
 
S

Scott M.

So my questions:
1. Can I use frames in such a way as to allow VS to actually accept and
compile the syntax?

Yes, but you need to specify that you wish to use the HTML 4.01 Frameset
"flavor" of HTML in your DOCTYPE. You can do this by changing the validation
document of the page.
2. Does ASP.NET have an easier way to accomplish what I need to do?

Most sites I've seen that need to provide a printable something or other
simply have the user click a button, which causes a new window to open that
contains the data to be printed. This only requries some client-side
JavaScript and no frames at all.
 
J

John Kotuby

Thanks Scott...

Maybe I will just re-create the contents of the Content area in a new window
as you suggest. I just need to come up with a way to allow the user to enter
the printing preferences when he clicks the Print button on the original
page. The user preferences have nothing to do with the actual Printer
settings, but rather what content to include or exclude, depending on the
intended recipient of the printed document. Hmmm... maybe I can have 2
buttons on the Parent page... "Print Options" and "Print". Ok, sounds like
the way to go, as it appears that Microsoft is trying to bury the frames
concept eventually anyway.

Thanks again. A fresh perspective helps after a mind-bending day.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top