472,985 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

printing only part of a webform

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!!
Jul 21 '05 #1
3 2234
Many sites make use of media print CSS options as discussed here:
http://www.meyerweb.com/eric/article...ev/200001.html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Bryan Z" <Br****@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
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!!

Jul 21 '05 #2
using CSS for print layout and set display:none;

Tony
"Bryan Z" <Br****@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
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!!

Jul 21 '05 #3
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...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/article...ev/200001.html

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Bryan Z" <Br****@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
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!!


Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tor Inge Rislaa | last post by:
Showing an HTML file in part of a Webform Hi I have a Webform with some buttons on the left side of the form. What I want when clicking one of the buttons is to show an HTML document in a part...
3
by: aniljain50 | last post by:
Hi All, I have a web form. let's say it has 3 fields. Employee No, Name ansd salary. Now my problem is I want to print the contents of this screen to a local printer. Note that this is client side...
0
by: mg | last post by:
How can I disable or hide the toolbar/printing in a C#/JavaScript WebForm without having to manually close an opening window?
1
by: MrMike | last post by:
Hi. I have a webform which I need to print automatically to a specific printer once it is opened. I've searched all around but I can't find the code to achieve ths. Basically I assume I just...
13
by: Nikolay Seksenov | last post by:
Does anybody has an experince printing from the web server using System.Drawing.Printing.PrintDocument object in dotNet web app? It works fine in windows apps but fails in web apps. Any...
3
by: Bryan Z | last post by:
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...
3
by: Franck | last post by:
Hi, Is it possible to extract all controls from a webform and print them ? I'm currently trying to use a viewstate system but can't figure out how to retrieve control position. Thks for help.
1
by: Franck | last post by:
Hi, I need to build a server-side print system for any of my webform. I "just" need to print text, keep position (table,<tr>,<td>, etc) and replace controls with text. As it will be extended to...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.