|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.NET page, hiding certain controls when printingI 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 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 Show quoteHide quote "J Ames" <j_ames2***@yahoo.com> wrote in message news:ODKwmjbXGHA.1220@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 > 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 Show quoteHide quote "Jeff Dillon" <jeffdil***@hotmail.com> wrote in message news:OqEktnbXGHA.4988@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_ames2***@yahoo.com> wrote in message > news:ODKwmjbXGHA.1220@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 > >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 > > > > 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... Show quoteHide quote "gerry" <germ@nospam.nospam> wrote in message news:%23bmYHMnXGHA.508@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" <jeffdil***@hotmail.com> wrote in message > news:OqEktnbXGHA.4988@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_ames2***@yahoo.com> wrote in message >> news:ODKwmjbXGHA.1220@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 >> >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 >> > >> >> > > 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 Show quoteHide quote "Jeff Dillon" <jeffdil***@hotmail.com> wrote in message news:e17nHtnXGHA.4060@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" <germ@nospam.nospam> wrote in message > news:%23bmYHMnXGHA.508@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" <jeffdil***@hotmail.com> wrote in message > > news:OqEktnbXGHA.4988@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_ames2***@yahoo.com> wrote in message > >> news:ODKwmjbXGHA.1220@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 > >> >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 > >> > > >> > >> > > > > > > gerry wrote:
Show quoteHide quote > i'm not sure why you'd want print through a link rather than just This works in IE6, FF1+, Opera (all on Windows):-> 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 @media print { .noprint { display: none; } } Which browsers do you find go wrong with display:none? Andrew 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 Show quoteHide quote "Andrew Morton" <a**@in-press.co.uk.invalid> wrote in message news:uByQKHuXGHA.3808@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 > >
Check if TIF file in use
Data form wizard in VS.NET 2005 Request for permission of the type 'System.Security.Permissions.RegistryPermission...' failed How to draw graphics on a bitmap ? Tabelle collegate in Access [VB .Net 2005] Shared Methods In A Class ListView FocusedItem Tabbing not working in vb 6.0 forms form refresh? repaint? doevents? file system watcher prevents PC shutdown |
|||||||||||||||||||||||