473,893 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

print preview page question

I need to create a print preview page BUT my page I need to print has a grid
and in the grid I have 2 or 3 columns that have links I want to hide the
columns with the links on my print preview page so they don't print. Is that
possible to do and if so can someone point me somewhere or show my a code
snippet on how to do this?

Oct 13 '06 #1
9 4082
Hi,

You can do this by using different CSS rules for "screen" and "print" mode:

1) Add following stylesheet to your WebForm:

<style type="text/css" media="print">
.printOnly {
display: none;
}
</style>

<style type="text/css" media="screen">
.printOnly {
display: block;
}
</style>
2) Apply CSS class "printOnly" to your columns. Using GridView's BoundField
for example, we need to set 4 attributes:

<asp:BoundFie ld ControlStyle-CssClass="print Only"
HeaderStyle-CssClass="print Only" ItemStyle-CssClass="print Only"
FooterStyle-CssClass="print Only" DataField="Unit Price"
HeaderText="Uni tPrice" SortExpression= "UnitPrice" />

For more information about CSS and print, refer to:

http://www.pmob.co.uk/faqcss/tutorial03/index.htm
http://alistapart.com/articles/goingtoprint/

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 14 '06 #2
I can't get that working. I tried this before actually and the links in the
grid still showed in my print preview page

"Walter Wang [MSFT]" wrote:
Hi,

You can do this by using different CSS rules for "screen" and "print" mode:

1) Add following stylesheet to your WebForm:

<style type="text/css" media="print">
.printOnly {
display: none;
}
</style>

<style type="text/css" media="screen">
.printOnly {
display: block;
}
</style>
2) Apply CSS class "printOnly" to your columns. Using GridView's BoundField
for example, we need to set 4 attributes:

<asp:BoundFie ld ControlStyle-CssClass="print Only"
HeaderStyle-CssClass="print Only" ItemStyle-CssClass="print Only"
FooterStyle-CssClass="print Only" DataField="Unit Price"
HeaderText="Uni tPrice" SortExpression= "UnitPrice" />

For more information about CSS and print, refer to:

http://www.pmob.co.uk/faqcss/tutorial03/index.htm
http://alistapart.com/articles/goingtoprint/

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 18 '06 #3
i got the test code working but when i put it in my app its still showing the
links from my grid on my print preview page. I'm using a master page does
that make a difference? Here is what i have

<asp:GridView >
<asp:TemplateFi eld InsertVisible=" False" HeaderText="H"
ControlStyle-CssClass="print Only">
<ItemTemplate>< a href="www.msn.c om">MSN</ItemTemplate>
</asp:GridView>
when I do print preview the link is still there, even when i go to my print
preview page its still there.

my print preview page:

function printpr(OLECMDI D)
{
if (opener && !window.opener. closed)
{
document.writel n(opener.docume nt.getElementBy Id(tbl).outerHT ML);
}
}
the grid appears here from the page calling it.
Is there an easier way to do this?
<asp:GridView
ID="GridView1" runat="server">
"Walter Wang [MSFT]" wrote:
Hi,

Which browser are you using? I just re-tested my test project using IE,
FireFox and Opera, all are working correctly by not showing the link column
in print preview mode.

I've attached my test web site here for your reference. Please tell me
whether or not this works for you. You might need to use Outlook Express to
download the attachment.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights
Oct 25 '06 #4
i got it working. though its still showing on my print preview page, the link
columns aren't printing. so I'm all set thanks

"igotyourdotnet " wrote:
i got the test code working but when i put it in my app its still showing the
links from my grid on my print preview page. I'm using a master page does
that make a difference? Here is what i have

<asp:GridView >
<asp:TemplateFi eld InsertVisible=" False" HeaderText="H"
ControlStyle-CssClass="print Only">
<ItemTemplate>< a href="www.msn.c om">MSN</ItemTemplate>
</asp:GridView>
when I do print preview the link is still there, even when i go to my print
preview page its still there.

my print preview page:

function printpr(OLECMDI D)
{
if (opener && !window.opener. closed)
{
document.writel n(opener.docume nt.getElementBy Id(tbl).outerHT ML);
}
}
the grid appears here from the page calling it.
Is there an easier way to do this?
<asp:GridView
ID="GridView1" runat="server">
"Walter Wang [MSFT]" wrote:
Hi,

Which browser are you using? I just re-tested my test project using IE,
FireFox and Opera, all are working correctly by not showing the link column
in print preview mode.

I've attached my test web site here for your reference. Please tell me
whether or not this works for you. You might need to use Outlook Express to
download the attachment.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights
Oct 25 '06 #5
Hi,

Thank you very much for the update.

From your reply, it seems you're using your own "print preview page" using
some javascript? If this is the case, then the CSS rules will not work.
Previously I have thought "print preview" is using browser (such as IE) 's
print preview function.

However, it's still possible to hide some elements on demand, you just need
to apply different class to the client-side elements using javascript when
showing your print preview page.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 26 '06 #6
how could i do that with my own print preview page?
I would prefer not to how the links on my print preview page, as well, even
though they don't actually print, I would still like to hide them on the
preview page if possible.
"Walter Wang [MSFT]" wrote:
Hi,

Thank you very much for the update.

From your reply, it seems you're using your own "print preview page" using
some javascript? If this is the case, then the CSS rules will not work.
Previously I have thought "print preview" is using browser (such as IE) 's
print preview function.

However, it's still possible to hide some elements on demand, you just need
to apply different class to the client-side elements using javascript when
showing your print preview page.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 26 '06 #7
nevermind I just figured it out. thanks

I added the class to my output label on my print preview page.

"igotyourdotnet " wrote:
how could i do that with my own print preview page?
I would prefer not to how the links on my print preview page, as well, even
though they don't actually print, I would still like to hide them on the
preview page if possible.
"Walter Wang [MSFT]" wrote:
Hi,

Thank you very much for the update.

From your reply, it seems you're using your own "print preview page" using
some javascript? If this is the case, then the CSS rules will not work.
Previously I have thought "print preview" is using browser (such as IE) 's
print preview function.

However, it's still possible to hide some elements on demand, you just need
to apply different class to the client-side elements using javascript when
showing your print preview page.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 26 '06 #8
I do have one question though, is there a way to force the print preview page
to print in landscape?

"Walter Wang [MSFT]" wrote:
Hi,

Thank you very much for the update.

From your reply, it seems you're using your own "print preview page" using
some javascript? If this is the case, then the CSS rules will not work.
Previously I have thought "print preview" is using browser (such as IE) 's
print preview function.

However, it's still possible to hide some elements on demand, you just need
to apply different class to the client-side elements using javascript when
showing your print preview page.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 26 '06 #9
Based on your description, you're using following javascript to write out
html source as your own print preview page:

function printpr(OLECMDI D)
{
if (opener && !window.opener. closed)
{
document.writel n(opener.docume nt.getElementBy Id(tbl).outerHT ML);
}
}

I guess you don't have pagination in that way, right?

The difference of Portrait and Landscape is the page orientation when
viewing in preview mode. If you don't have pagination, then you need to
control the preview page width in different mode, I think you may use some
CSS rules to control the width.

By the way, can I ask why you need to implement the print preview while the
browser already has one? Also, the printing is still done by the browser,
right?

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 27 '06 #10

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

Similar topics

16
11448
by: Neo Geshel | last post by:
I'm helping on a web site, and it's got our knickers in a knot. We're using the same basic CSS files (with mods) and same headers as from our other sites, but the "print preview" won't work correctly on this site. The site is here: http://askdrray.kabis.net (temporary location) The site is being worked on, and only the front page works right now. Expect constant changes. Ignore everything “below the fold”, as the links there...
1
5729
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
4
3125
by: zz | last post by:
Sorry for posting this here but unfortunatly I couldn't find any appropriate newsgroup for this and since I've been active here with .net question I figured you guys might be able to help. This is a link to a very simple page that contains 2 DIV statements: http://xsinx.no-ip.com:8880/TestEmbedDiv.html One of them is embeded in the other. There is some clipping involved (the red layer is smaller than the yellow one). If you look at...
0
1646
by: ShaneO | last post by:
There have been similar questions raised in the past, however no answers seem to have been provided, so I thought I'd give it a go. Scenario 1: My Windows Forms app generates (say) 10 pages in a Print Preview Control. These pages are made up of varying sized graphics and text, therefore each page is unique but does rely on the content of the previous page to determine the final page layout. My User wants to print ALL pages, pages 1 &...
6
3489
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page and not show the templated fields, (hyperlinks) and also not print those fields?
7
3490
by: itm | last post by:
I have a mail out to send to a group of owners with multiple accounts. I want to limit the number of accounts that print on the first page to 20. I want remaining accounts to print on a second page. Is there a way to accomplish this? Thanks so much for your help!
16
3783
by: kcddoorman | last post by:
Ok my database is working great. I've entered a whole bunch of orders into it and it is getting bigger. Say I have 3000 records and I want to print the form for the last 13. I go to print preview and hit the end button and find out what pages I want to print (by the way I have 2 records/orders on each page). This process of going through and ?formating the information and showing a preview takes for ever. Is there a way to make it faster by...
2
9991
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default printer settings to print. I wanted the print preview to appear the same for all users (i.e. a default page size of 8.5x14 (legal) and portrait mode). Many users have different printers as their default (plotters etc..) and I found that various...
7
3428
by: Fareast Adam | last post by:
I try to hide the print preview button that inside <div id="button"> when previewing the page. But the the problem happened the button is always hidden after i closing the preview page. Anyone have an idea how to overcome this? Here is the code; <html> <head> <script language="javascript"> function printpreview() { var OLECMDID = 7; /* OLECMDID values: * 6 - print
0
9987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11245
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10840
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9647
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7175
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5859
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4281
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.