Refer
@model ViewCari
@{
ViewBag.Title = "SatisYazdir";
Layout = "~/Views/Shared/View.cshtml";
}
<div id="dvContent">
<div style="text-align:center">
<button class="btn" style="font-size:45px;" onclick="window.print()">@ViewBag.firmaad</button>
<h5>@ViewBag.firmaadres</h5>
<img style="width:200px;height:50px" src="@ViewBag.firmalogo" />
</div>
<br />
<h6>Fiş No: @ViewBag.fisid Tarih: @DateTime.Today.ToString("dd.MM.yyyy")</h6>
<h6>Müşteri Adı: @ViewBag.cariad</h6>
<table class="table">
<tr>
<th>Stok Adı</th>
<th>Miktar</th>
<th>Fiyat</th>
<th>Tutar</th>
</tr>
@foreach (var c in Model.WEBSATISLAR_Results)
{
<tr>
<td>@c.STOKADI</td>
<td>@c.MIKTAR</td>
<td>@((System.Data.SqlTypes.SqlMoney?)c.FIYAT) ₺</td>
<td>@((System.Data.SqlTypes.SqlMoney?)c.TUTAR) ₺</td>
</tr>
}
</table>
<div style="float:right">
<h6>Toplam: @((System.Data.SqlTypes.SqlMoney?)ViewBag.tutar) ₺</h6>
<h6>Eski Bakiye: @((System.Data.SqlTypes.SqlMoney?)ViewBag.eskibakiye) ₺</h6>
<h6>Genel Toplam: @((System.Data.SqlTypes.SqlMoney?)ViewBag.geneltoplam) ₺</h6>
<h6>Tahsilat: @((System.Data.SqlTypes.SqlMoney?)ViewBag.tahtutar) ₺</h6>
<h6>Kalan: @((System.Data.SqlTypes.SqlMoney?)ViewBag.kalan) ₺</h6>
</div>
</div
Call the following code on button click.
var divToPrint = document.getElementById("dvContent");
var printWindow = window.open('', '', 'height=500,width=1000');
printWindow.document.write('<html><head><title></title>');
printWindow.document.write('</style>');
printWindow.document.write('</head>');
printWindow.document.write('<body>');
printWindow.document.write("<center>header</center>");
printWindow.document.write(divToPrint.outerHTML);
printWindow.document.write('</body>');
printWindow.document.write('</html>');
printWindow.document.close();
printWindow.print();