简体   繁体   中英

Avoid Printing HTML tag on ASP.NET

I'm trying to find a way to avoid printing (either through a printer or to a PDF file) a specific HTML tag on my ASP.NET project view file.

Is there any HTML or CSS attribute which allows me to do that? How should it be set?

I've tried to follow some answers on other similar questions here at StackOverflow and none of them worked.

Here is the HTML code I'm trying to hide on printing.

<a href="@Url.Action(/*att1*/,/*att2*/)">PRINT</a>

Cheers!

Sure, there's several selectors for that. Example;

 @media print { a[href*="@Url.Action(/*att1*/,/*att2*/)"] { font-size: 150%; color: red; /*display: none;*/ } } 
 <a href="@Url.Action(/*att1*/,/*att2*/)">PRINT</a> 

Or in your case specifically, you would just add say display: none; to the CSS block in the example.

Sorry, I thought you meant hiding your html code, that's why shared those javascript encryptions. I found this website during a search for your answer, it seems this guy had the same problem like you. I hope this would solve your problem.

Printing Page not printing link/button

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM