4
I need to print the contents of a view on the default printer. How can I do this using c# or javascript?
4
I need to print the contents of a view on the default printer. How can I do this using c# or javascript?
1
An alternative is you call the function print()
of JavaScript
. That would be your code:
This CSS only serves to not show the print button by clicking on it
@media print
{
.no-print, .no-print *
{
display: none !important;
}
}
And in his View
you add the print button
<div>
<h3>Teste Impressão!</h3>
</div>
<div class="no-print">
<button type="button" value="imprimir" onclick="window.print();">Imprimir</button>
</div>
And in his View
you add the print button.
You can see the example working on Dotnetfiddle.
Browser other questions tagged javascript c# asp.net-mvc impression
You are not signed in. Login or sign up in order to post.
Blz plus the content to be printed will be from my view ?
– Hans Miller
@Hansmiller content will be whatever is in your View.
– Randrade
@Hansmiller I edited the answer with an example.
– Randrade
has how to make the command print directly or is automatically not needing to confirm the printer?
– Hans Miller