Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In windows application I use the following javascript code to print a datagridview 'gvuserinfo'.
The form runs without error but I could not see the 'print' button. The same javascript code with web page works fine. How to solve this?

XML
public MaterialsToBeReadyReport()
        {
con.ConnectionString = Constring;
InitializeComponent();
webBrowser1.DocumentText =
@"<html><head>
<script type='text/javascript'>
function PrintGridData() {
var prtGrid = document.getElementById('<%=gvUserInfo.ClientID %>');
prtGrid.border = 0;
var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=500,height=500,tollbar=0,scrollbars=1,status=0,resizable=1');
prtwin.document.write(prtGrid.outerHTML);
prtwin.document.close();
prtwin.focus();
prtwin.print();
prtwin.close();
}
</script>
</head><body></body></html>";
webBrowser1.Document.InvokeScript("PrintGridData");
Posted

1 solution

You cannot use JavaScript code in windows forms - at least not directly.
You can run JavaScript in an html control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900