I want to show a print in table format(design ) in c# mvc.
The problem is that i am getting only the content and not in table format..
This is my Print button.
<input id="printdiv" type="submit" value="Print" onclick="return PrintDiv();" />
This is my Partial view div.
<div id="dvmismatch" style="display :none;">
@Html.Partial("_MismatchVendorList", Model)
</div>
This is my Script..
<script type="text/javascript">
var $ = jQuery.noConflict();
function PrintDiv() {
$("#dvmismatch").show();
$("#dvmismatch").print();
$("#dvmismatch").hide();
}
</script>
plz give me the Suggestions...
i want to Print a div with HTML in a Partial view in mvc 4 with C# using JavaScript..But showing only the table Content. Not the Content with Table Format????
I want to show a print in table format(design ) in c# mvc.
The problem is that i am getting only the content and not in table format..
This is my Print button.
<input id="printdiv" type="submit" value="Print" onclick="return PrintDiv();" />
This is my Partial view div.
<div id="dvmismatch" style="display :none;">
@Html.Partial("_MismatchVendorList", Model)
</div>
This is my Script..
<script type="text/javascript">
var $ = jQuery.noConflict();
function PrintDiv() {
$("#dvmismatch").show();
$("#dvmismatch").print();
$("#dvmismatch").hide();
}
</script>
plz give me the Suggestions...
i want to Print a div with HTML in a Partial view in mvc 4 with C# using JavaScript..But showing only the table Content. Not the Content with Table Format????
Share Improve this question edited Aug 26, 2016 at 10:40 Rizwana Ahmed asked Aug 26, 2016 at 10:28 Rizwana AhmedRizwana Ahmed 431 gold badge1 silver badge7 bronze badges1 Answer
Reset to default 4Try This
Javascript
<script>
function printContent(el){
var restorepage = document.body.innerHTML;
var printcontent = document.getElementById(el).innerHTML;
document.body.innerHTML = printcontent;
window.print();
document.body.innerHTML = restorepage;
}
</script>
Button
<input id="printdiv" type="submit" value="Print" onclick="printContent('dvmismatch')" />
This is Partial view div.
<div id="dvmismatch" style="display :none;">
@Html.Partial("_MismatchVendorList", Model)
</div>