473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

ASP.NET page, hiding certain controls when printing

I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a
button. The button invokes a stored procedure and several tables are
created on the page with data populated. I want to create a link to print
the page, but I don't want the drop downs or the button to print, only the
tables. How can this be done? I know how to use a CSS file to disallow the
entire page from being printed, but I don't know how to apply this to only
certain controls. Any advice is greatly appreciated.

Thanks
Apr 11 '06 #1
6 2102
Private Sub lnkPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lnkPrint.Click

m_bPrint = True

GetDBData()

UpdateDataView()

Me.NavigationControl1.Visible = False

Me.NavigationControl2.Visible = False

Me.lnkPrint.Visible = False

Me.imgPrint.Visible = False

Me.lblAppTitle.Font.Size = m_fntUnit

Me.lblBanner.Font.Size = m_fntUnit

Me.lblReportHeader.Font.Size = m_fntUnit

Me.lblLoginBar.Font.Size = m_fntUnit

Me.dgDataGrid.Font.Size = m_fntUnit

m_bPrint = False

Response.Write("<script>window.print();</script>")

End Sub

"J Ames" <j_********@yahoo.com> wrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and
a button. The button invokes a stored procedure and several tables are
created on the page with data populated. I want to create a link to print
the page, but I don't want the drop downs or the button to print, only the
tables. How can this be done? I know how to use a CSS file to disallow
the entire page from being printed, but I don't know how to apply this to
only certain controls. Any advice is greatly appreciated.

Thanks

Apr 11 '06 #2
i'm not sure why you'd want print through a link rather than just using the
browsers print menu item.
this sure seems like doing things the hard way
just setup a second css and include it in your AFTER all other stylesheets
include the attribue media="print"

create a class in this stylesheet create a class as such :
..noprint
{
position:absolute;
top:-10000;
}
just making items invisible causes havoc with some browsers - you have to
physically move these items out of view
you may have to play with visible, width , height as well.
and override any other classes' attributes as required - font size ,
positions etc.

then assign this class to any items you want to hide when printing

<input type='button' class='noprint />

You can use this technique to print something completely different than what
is viewed in the browser by over riding class properties.

You can also use this technique to hide items in the browser view and
display them when printing

check out http://www.hgha.ca/Rep/PeeweeB.htm?tab=Schedule (or any other page
on this site ) and compare what you see in the browser to what you see in
print/preview.

Gerry


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
Private Sub lnkPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lnkPrint.Click

m_bPrint = True

GetDBData()

UpdateDataView()

Me.NavigationControl1.Visible = False

Me.NavigationControl2.Visible = False

Me.lnkPrint.Visible = False

Me.imgPrint.Visible = False

Me.lblAppTitle.Font.Size = m_fntUnit

Me.lblBanner.Font.Size = m_fntUnit

Me.lblReportHeader.Font.Size = m_fntUnit

Me.lblLoginBar.Font.Size = m_fntUnit

Me.dgDataGrid.Font.Size = m_fntUnit

m_bPrint = False

Response.Write("<script>window.print();</script>")

End Sub

"J Ames" <j_********@yahoo.com> wrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule anda button. The button invokes a stored procedure and several tables are
created on the page with data populated. I want to create a link to printthe page, but I don't want the drop downs or the button to print, only thetables. How can this be done? I know how to use a CSS file to disallow
the entire page from being printed, but I don't know how to apply this to
only certain controls. Any advice is greatly appreciated.

Thanks


Apr 12 '06 #3
NoPrint didn't want to work with usercontrols. I'm sure I could get it to
work if I kept at it.

We are an IE only shop here..

Plus the users WANTED a print button. Yahoo, MapQuest and many others have a
print button

But I hear ya...

"gerry" <ge**@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
i'm not sure why you'd want print through a link rather than just using
the
browsers print menu item.
this sure seems like doing things the hard way
just setup a second css and include it in your AFTER all other stylesheets
include the attribue media="print"

create a class in this stylesheet create a class as such :
.noprint
{
position:absolute;
top:-10000;
}
just making items invisible causes havoc with some browsers - you have to
physically move these items out of view
you may have to play with visible, width , height as well.
and override any other classes' attributes as required - font size ,
positions etc.

then assign this class to any items you want to hide when printing

<input type='button' class='noprint />

You can use this technique to print something completely different than
what
is viewed in the browser by over riding class properties.

You can also use this technique to hide items in the browser view and
display them when printing

check out http://www.hgha.ca/Rep/PeeweeB.htm?tab=Schedule (or any other
page
on this site ) and compare what you see in the browser to what you see in
print/preview.

Gerry


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
Private Sub lnkPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lnkPrint.Click

m_bPrint = True

GetDBData()

UpdateDataView()

Me.NavigationControl1.Visible = False

Me.NavigationControl2.Visible = False

Me.lnkPrint.Visible = False

Me.imgPrint.Visible = False

Me.lblAppTitle.Font.Size = m_fntUnit

Me.lblBanner.Font.Size = m_fntUnit

Me.lblReportHeader.Font.Size = m_fntUnit

Me.lblLoginBar.Font.Size = m_fntUnit

Me.dgDataGrid.Font.Size = m_fntUnit

m_bPrint = False

Response.Write("<script>window.print();</script>")

End Sub

"J Ames" <j_********@yahoo.com> wrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
>I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and >a button. The button invokes a stored procedure and several tables are
>created on the page with data populated. I want to create a link to print >the page, but I don't want the drop downs or the button to print, only the >tables. How can this be done? I know how to use a CSS file to disallow
>the entire page from being printed, but I don't know how to apply this
>to
>only certain controls. Any advice is greatly appreciated.
>
> Thanks
>



Apr 12 '06 #4
wrap your user control content in a panel and add the noprint class to the
panel's CssClass attribute or in a div and add noprint to the div class - it
works - make sure this isn't a typo or a case issue
"Jeff Dillon" <je********@hotmail.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
NoPrint didn't want to work with usercontrols. I'm sure I could get it to
work if I kept at it.

We are an IE only shop here..

Plus the users WANTED a print button. Yahoo, MapQuest and many others have a print button

But I hear ya...

"gerry" <ge**@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
i'm not sure why you'd want print through a link rather than just using
the
browsers print menu item.
this sure seems like doing things the hard way
just setup a second css and include it in your AFTER all other stylesheets include the attribue media="print"

create a class in this stylesheet create a class as such :
.noprint
{
position:absolute;
top:-10000;
}
just making items invisible causes havoc with some browsers - you have to physically move these items out of view
you may have to play with visible, width , height as well.
and override any other classes' attributes as required - font size ,
positions etc.

then assign this class to any items you want to hide when printing

<input type='button' class='noprint />

You can use this technique to print something completely different than
what
is viewed in the browser by over riding class properties.

You can also use this technique to hide items in the browser view and
display them when printing

check out http://www.hgha.ca/Rep/PeeweeB.htm?tab=Schedule (or any other
page
on this site ) and compare what you see in the browser to what you see in print/preview.

Gerry


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP05.phx.gbl...
Private Sub lnkPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lnkPrint.Click

m_bPrint = True

GetDBData()

UpdateDataView()

Me.NavigationControl1.Visible = False

Me.NavigationControl2.Visible = False

Me.lnkPrint.Visible = False

Me.imgPrint.Visible = False

Me.lblAppTitle.Font.Size = m_fntUnit

Me.lblBanner.Font.Size = m_fntUnit

Me.lblReportHeader.Font.Size = m_fntUnit

Me.lblLoginBar.Font.Size = m_fntUnit

Me.dgDataGrid.Font.Size = m_fntUnit

m_bPrint = False

Response.Write("<script>window.print();</script>")

End Sub

"J Ames" <j_********@yahoo.com> wrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
>I have an ASP.NET (VB) form that has two drop downs, a horizontal rule

and
>a button. The button invokes a stored procedure and several tables are >created on the page with data populated. I want to create a link to

print
>the page, but I don't want the drop downs or the button to print, only

the
>tables. How can this be done? I know how to use a CSS file to disallow >the entire page from being printed, but I don't know how to apply this
>to
>only certain controls. Any advice is greatly appreciated.
>
> Thanks
>



Apr 13 '06 #5
gerry wrote:
i'm not sure why you'd want print through a link rather than just
using the browsers print menu item.
this sure seems like doing things the hard way

just setup a second css and include it in your AFTER all other
stylesheets include the attribue media="print"

create a class in this stylesheet create a class as such :
.noprint
{
position:absolute;
top:-10000;
}
just making items invisible causes havoc with some browsers - you
have to physically move these items out of view


This works in IE6, FF1+, Opera (all on Windows):-

@media print
{
.noprint
{
display: none;
}
}

Which browsers do you find go wrong with display:none?

Andrew
Apr 13 '06 #6
Hi Andrew,
off the top I don't recall - seems to me it was netscape 8 and under some
circumstance this resulted in a black hole being rendered where the hidden
element would otherwise appear.
I just did a quick test and couldn't get it to happen so I'm not sure what
the exact details were - I guess that's the kind of thing I should be
keeping track of.

It could be that this is a doh! moment and the problem was actually with
trying to use visibility:hidden rather than display:none

Gerry

"Andrew Morton" <ak*@in-press.co.uk.invalid> wrote in message
news:uB**************@TK2MSFTNGP04.phx.gbl...
gerry wrote:
i'm not sure why you'd want print through a link rather than just
using the browsers print menu item.
this sure seems like doing things the hard way

just setup a second css and include it in your AFTER all other
stylesheets include the attribue media="print"

create a class in this stylesheet create a class as such :
.noprint
{
position:absolute;
top:-10000;
}
just making items invisible causes havoc with some browsers - you
have to physically move these items out of view


This works in IE6, FF1+, Opera (all on Windows):-

@media print
{
.noprint
{
display: none;
}
}

Which browsers do you find go wrong with display:none?

Andrew

Apr 13 '06 #7

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

Similar topics

2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
by: bhav | last post by:
Hi Guys, I have a Web Forms' 'Table' control in my default.aspx page, along with other controls. I wanted to implement a functionality where a user can click a button to open the table's...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
3
by: abcd | last post by:
I have 3 controls placed in a table in each row Row1 --> DropDownlist Web server control Row2 --> Text box control Row3--> list box control Row 4--> update and delete buttons each control...
6
by: J Ames | last post by:
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a button. The button invokes a stored procedure and several tables are created on the page with data populated. I want...
4
by: Bob Alston | last post by:
Anyone have any code handy for handling logical paging when using tabs to handle a multiple page form? What I have read, you can make each tab one of the pages, hide all but the active tab and...
7
kvijayhari
by: kvijayhari | last post by:
hi i've doubt in the window.print() function. I'm using a css with the attribute media=print and i'm hiding the unwanted things from display for printing using this css. I'm opening a window...
4
by: Joe Kovac | last post by:
Hi! I would like to create a page, where the user can print the lower part of the page by pressing a button. It might look like this: ----------------------------------------------- o...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.