Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / January 2005

Tip: Looking for answers? Try searching our database.

printing only part of a webform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bryan Z - 19 Jan 2005 20:11 GMT
I was wondering how do you print just part of a webform in asp.net -- like
just printing the contents of a textbox or label.  I know that it will
involve javascript, but I cannot get the javascript function to work.  
Basically, this is the scenario ---

A simple web page with a search form.  User enters search value, and a
datagrid displays what the search returns with a template column to link to
the details of each record found.  Template column link brings up a textbox
that displays a long list of text (stored in sql as sqldbtype.text).  Then I
have a close button and a print button for just this textbox.  What I want to
do is just print what is in the textbox.  I have written something for which
it will print, but it opens a new page and pressing back does not take you
back to the form displaying the original textbox.

As an example, in Microsoft's Knowledge Base, when you open one of the
articles, there is a link on the right that says Print this page.  You click
it, and it pops up the print dialog box, and then you click Ok, and it prints
just the article --- not all the other stuff on the page.  That is what I'd
like to be able to do.  But, I do not really care.  Just opening a new page
with just the text from the text box in it would be ok with me.

Any help would be much appreciated --- Thanks!!
John Timney \(ASP.NET MVP\) - 19 Jan 2005 23:03 GMT
Many sites make use of media print CSS options as discussed here:
http://www.meyerweb.com/eric/articles/webrev/200001.html

Signature

Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

> I was wondering how do you print just part of a webform in asp.net -- like
> just printing the contents of a textbox or label.  I know that it will
[quoted text clipped - 18 lines]
>
> Any help would be much appreciated --- Thanks!!
Bryan Z - 20 Jan 2005 14:19 GMT
Thanks for the info.  I actually found another way of doing it, but I'll have
to look into using CSS style sheets also.

I ended up removing my textbox.  Then I put in a div tag with runat server
and then what was going into the textbox went between the div tags instead.  
Then I had a hidden iframe at the end of aspx page and when users clicked the
print button, it set the src for the iframe to a printer page template i
created and some javascript in this template page copied the text in the
parent document div tag to the div tag on the template page.  Works pretty
good as far as I can see, have to wait and see how the users like it though.  
I got this idea from a web page I found yesterday after "HOURS" of searching.
Here's the link if you'd like more info:
http://www.ftponline.com/vsm/2004_10/magazine/columns/aspnet

The iframe stuff starts on page 2 of the article.

"John Timney (ASP.NET MVP)" wrote:

> Many sites make use of media print CSS options as discussed here:
> http://www.meyerweb.com/eric/articles/webrev/200001.html
[quoted text clipped - 30 lines]
> >
> > Any help would be much appreciated --- Thanks!!
Tony - 20 Jan 2005 00:18 GMT
using CSS for print layout and set display:none;

Tony
> I was wondering how do you print just part of a webform in asp.net -- like
> just printing the contents of a textbox or label.  I know that it will
[quoted text clipped - 18 lines]
>
> Any help would be much appreciated --- Thanks!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.