Sneha K

Sneha K

  • 1.2k
  • 527
  • 195.9k

How to give print button in view and print directly in MVC4?

Mar 30 2016 9:26 AM
My problem is in View when i click on print button it is downloading the report in pdf format but i need to print that report directly when the button is clicked.
 
My View code
 
 
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/jquery-ui.min.js"></script>
<div class="col-xs-12 " >
<div class="box">
<div class="box-header">
<div class="text-center">
<h2 style="color: #0000FF">Customer Type Report</h2>
</div>
</br>
</br>
<div class="box-body">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<div class="box-body">
<input type="button" value="Print Form" onclick="window.print()" />
<table id="CustomerTable" class="table table-bordered table-striped">
<thead>
<tr>
<th style="color: #1a1ae9">Customer Name</th>
<th style="color:#1a1ae9">Customer Type</th>
</tr>
</thead>
<tbody>
@foreach (var i in Model)
{
<tr>
<td>
@i.CustomerName
</td>
<td>
@i.CustomerType
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<th style="color: #1a1ae9">Customer Name</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>

Answers (1)