chiranjeevi mugibari

chiranjeevi mugibari

  • 1.5k
  • 230
  • 8.6k

pass parameter to javascript function

Sep 1 2016 9:28 AM
how to pass parameter from aspx.cs page to java script function
 
htmlbutton.Append("<table width='100%' cellpadding='2' cellspacing='2'><tr><td align='center'><input type='button' id='btnPrint' class='btn btn-theme' onclick='PrintDiv();' value='Print' /></td></tr></table>");
htmlTablenew.Append(htmlbutton.ToString() + "<hr>");
htmlbutton.Clear();
 
javascript function 
 
 
<script type="text/javascript">
function PrintDiv() {
var contents = document.getElementById("tdi").innerHTML;
var frame1 = document.createElement('iframe');
frame1.name = "frame1";
frame1.style.position = "absolute";
frame1.style.top = "-1000000px";
document.body.appendChild(frame1);
var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.document.open();
frameDoc.document.write('<html><head><title>DTM</title>');
frameDoc.document.write('</head><body>');
frameDoc.document.write(contents);
frameDoc.document.write('</body></html>');
frameDoc.document.close();
setTimeout(function () {
window.frames["frame1"].focus();
window.frames["frame1"].print();
document.body.removeChild(frame1);
}, 500);
return false;
}
</script>
 

Answers (4)