do NOT print something on page (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


dzirkelb1 -> do NOT print something on page (2/27/2009 13:24:09)

I remember a loooong time ago, or at least I do, that you could tag some portion of the web page to not be printed when you did a file print. Is this possible and if so, anyone remember how to do it?




Tailslide -> RE: do NOT print something on page (2/27/2009 15:53:52)

I use a print stylesheet to specify what's printed and what's not. Just set up a separate styelsheet for print and specify display:none; for any elements you don't want printed such as navigation or footer etc.




dzirkelb1 -> RE: do NOT print something on page (2/27/2009 15:58:00)

My CSS skills are 0...so could you show me how to add it into this page?

<!-- #include file="dbQS.asp" -->
<%
strPONumber = request.querystring("PONumber")

ssql = "DELETE FROM RcvgLabels"
dbc.execute(ssql)

ssql = "INSERT INTO RcvgLabels ( [PO Number], [Part #], [Qty Recd], [DEE ORDER #], Customer, [Mfg Name], ID, Locator, CUSTNAME, [PO #], INSPECT )"
ssql = ssql & " SELECT PORECGS1.[PO Number], INVENTORYMASTER1.[Part #], PORECGS1.[Qty Recd], PORECGS1.[DEE ORDER #], PORECGS1.Customer, INVENTORYMASTER1.[Mfg Name], INVENTORYMASTER1.ID, INVENTORYMASTER1.Locator, PORECGS1.Customer AS CUSTNAME, PORECGS1.[PO Number] AS [PO #], INVENTORYMASTER1.INSPECT"
ssql = ssql & " FROM INVENTORYMASTER1 INNER JOIN PORECGS1 ON INVENTORYMASTER1.[Part #] = PORECGS1.[Part #]"
ssql = ssql & " WHERE (PORECGS1.[PO Number] = '"&strPONumber&"') AND (PORECGS1.TAG <> 0)"
dbc.execute(ssql)

ssql = "UPDATE PORECGS1 SET TAG = 0 WHERE (TAG <> 0) AND ([PO Number] = '"&strPONumber&"')"
dbc.execute(ssql)

set rs = server.CreateObject("adodb.Recordset")
ssql = "SELECT ID, [Part #] AS Part, [Mfg Name] AS Mfg, CUSTNAME, [PO #] AS PO, [DEE ORDER #] AS OrderNum, ID, INSPECT"
ssql = ssql & " FROM RcvgLabels"
rs.Open ssql, dbc, adOpenForwardOnly,adLockReadOnly

set rs1 = server.CreateObject("adodb.Recordset")
ssql = "SELECT OH, OO FROM INVENTORYMASTER1 WHERE ([Part #] = '"&rs("Part")&"')"
rs1.Open ssql, dbc, adOpenForwardOnly,adLockReadOnly

if not rs1.eof then
	intOH = rs1("OH")
	intOO = rs1("OO")
end if

rs1.close
set rs1=nothing

set rs1 = server.CreateObject("adodb.Recordset")
ssql = "SELECT [Qty Recd] AS QtyReceived FROM PORECGS1 WHERE ([PO Number] = '"&strPONumber&"')"
rs1.Open ssql, dbc, adOpenForwardOnly,adLockReadOnly

if not rs1.eof then
	intQtyReceived = rs1("QtyReceived")
end if

rs1.close
set rs1=nothing

intOH = intOH + intQtyReceived
intOO = intOO - intQtyReceived

ssql = "UPDATE INVENTORYMASTER1 SET OH = "&intOH&", OO = "&intOO&" WHERE ([PART #] = '"&rs("Part")&"')"
dbc.execute(ssql)
%>

<html>
<head>
<title>Print Receiving Label</title>
</head>

<body>

<object classid="clsid:0C3874AA-AB39-4B5E-A768-45F3CE6C6819" id="BarCode1" width="116" height="28">
  <param name="_cx" value="6000">
  <param name="_cy" value="2000">
  <param name="Enabled" value="-1">
  <param name="AutoSize" value="0">
  <param name="BackColor" value="16777215">
  <param name="Font" value="Arial">
  <param name="ForeColor" value="0">
  <param name="SymbologyId" value="13">
  <param name="DataToEncode" value="<%=rs("ID")%>">
  <param name="Orientation" value="0">
  <param name="BarHeight" value=".5">
  <param name="NarrowBarWidth" value="0.05">
  <param name="Wide2NarrowRatio" value="3">
  <param name="AddCheckDigit" value="1">
  <param name="AddCheckDigitToText" value="1">
  <param name="Code128CharSet" value="0">
  <param name="UPCESystem" value="0">
  <param name="EANUPCSupplement" value="0">
  <param name="ShowText" value="0">
  <param name="TopMarginCM" value="0.06">
  <param name="LeftMarginCM" value="0.1">
  <param name="CodabarStartCharacter" value="A">
  <param name="CodabarStopCharacter" value="B">
  <param name="SupplementToEncode" value>
  <param name="FixedResolutionCM" value="0">
  <param name="ApplyTilde" value="1">
  <param name="XDimensionMILS" value="11.81">
  <param name="CharacterGrouping" value="0">
  <param name="WhiteBarIncrease" value="0">
  <param name="BearerBarHorizontal" value="0">
  <param name="BearerBarVertical" value="0">
  <param name="TextMarginCM" value="0.03">
  <param name="PostnetHeightTallBar" value="0.3">
  <param name="PostnetHeightShortBar" value="0.125">
</object>
<br>
<font face="arial" style="font-size: 8pt"><b>
	<%=rs("Part")%>
	<br>
	<br>
	<%=rs("Mfg")%>
	<br>
	<%=rs("CustName")%>
	<br>
	<%=rs("PO")%>  <%=rs("OrderNum")%>  <%=rs("ID")%>  <%=rs("Inspect")%>
</b></font>
<br>
<font face="verdana" size="3"><a href="Receiving.asp">Back to Receiving</a></font>
</body>
<%
rs.close
set rs=nothing

dbc.close
set dbc=nothing
%></html>


I need this to not print:

<br>
<font face="verdana" size="3"><a href="Receiving.asp">Back to Receiving</a></font>




Tailslide -> RE: do NOT print something on page (2/28/2009 2:23:07)

Ok well the best thing would be to add a span and a class around the Back to Receiving link. (I'll ignore all the font tags!!)

So you want the code to end up with:

<span class="omit"><font face="verdana" size="3"><a href="Receiving.asp">Back to Receiving</a></font> </span>


Then you add a stylesheet link to the head of each page (note the media is specifically targetted at print rather than the normal screen):

<link rel="stylesheet" type="text/css" media="print" href="print.css"  />


(obviously you can change the path of wherever you want the stylesheet to live)

Then in this stylesheet - which is a blank document - nothing else at all in it you add:
.omit{display:none;}


Then you can add a span around any inline (not block elements like Ps) element and it will be omitted during printing.

To do this in a block element you can forget the span itself and just add the class="omit" to the paragraph tag or list tag or whatever the block element is. I used a span in this case as there wasn't any other hook I could use here.

Generally when I do this I don't need to add a specific class or a span around stuff because my pages have a load of divs with ids and classes already in them to style the page via the normal stylesheet. So generally I only have to refer to already existing ids and classes and elements without having to add in a span or a class specifically to exclude during printing - if that makes any sense. It''s part of the joy of CSS - it reduces the code required in the page itself.







dzirkelb1 -> RE: do NOT print something on page (3/2/2009 15:51:09)

That worked perfect, thanks!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
2.875