Hello team, am using bootstrp template in ASP.NET MVC and when I tried to print with this code it print buttons and the sidebar all together please can one help me. thank in advance.
$('#invoice-printed').click(function(){
Popup($('.invoice')[0].outerHTML);
function Popup(data)
{
window.print();
return true;
}
});
Vishal JoshiPosted Mar 19, 2023, 12:13 PM
Hello
Please try below code to get it work
Thanks
Emmmanuel FIADUFEPosted Mar 19, 2023, 10:34 PM
Thank you guys for your swift response, but Vishal's code has done the magic
Emmmanuel FIADUFEPosted Mar 18, 2023, 1:27 PM
Ohk Paul I will try and revert, thank you for the response
Tuhin PaulPosted Mar 18, 2023, 2:02 AM
Or you can enclose your CSS code in a
element in your Razor view, which will not require escaping the@symbolBy enclosing the CSS code in a
element, you can use the@symbol as usual without it being interpreted as Razor syntax.Tuhin PaulPosted Mar 18, 2023, 2:01 AM
To include a literal @ symbol in your CSS code, you can escape it using a backslash (\@).
Notice the backslash before the @ symbol in \#invoice-printed.
Tuhin PaulPosted Mar 18, 2023, 1:59 AM
Modify your JavaScript code to add the print.css stylesheet to the page before printing
The print.css stylesheet is added to the page before printing, which hides the sidebar and print button.
Tuhin PaulPosted Mar 18, 2023, 1:59 AM
Tuhin PaulPosted Mar 18, 2023, 1:57 AM
One way to fix this issue is to modify the CSS of the page so that only the content of the "invoice" element is visible when printing. You can do this by adding a print-specific CSS using the
@media printrule.Emmmanuel FIADUFEPosted Mar 17, 2023, 7:19 PM
Naimish I did but it didn't work, in MVC @ is not working in css I even used @@ but still it underlined it as error
Naimish MakwanaPosted Mar 17, 2023, 3:16 PM
If you want to exclude the sidebar and buttons when printing, you can add some CSS styles to hide them specifically for printing. For example:
You can add this CSS to your page, and it will hide any elements with the classes
sidebarandbuttonswhen the page is printed.Thanks
Naimish Makwana