Javascript Print method works in jsfiddle but not in asp.net -
i'm trying run function below in asp.net page using ie-11:
function openwin() { var mywindow=window.open('','','width=200,height=100'); mywindow.document.write("<p>this 'mywindow'</p>"); mywindow.document.close(); mywindow.focus(); print(mywindow); mywindow.close(); }
this runs on jsfiddle using internet explorer. however, when run asp.net web application in internet explorer, function causes internet explorer stop working , windows close.
this aspx page source:
<%@ page language="c#" autoeventwireup="true" codebehind="printbarcode.aspx.cs" inherits="application.barcode.printbarcode" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .titlelabel { font-size: large; font-weight: bold; } html { background-color: rgb(244,244,244); margin: 0; padding: 0; } </style> <script type="text/javascript"> function openwin() { var mywindow = window.open('', '', 'width=200,height=100'); mywindow.document.write("<p>this 'mywindow'</p>"); mywindow.document.close(); mywindow.focus(); print(mywindow); mywindow.close(); } </script> </head> <body> <form id="form1" runat="server"> <div> <table style="width: 100%"> <tr> <td> <asp:label id="lblbarcode" runat="server" text=" barcode" cssclass="titlelabel"></asp:label> </td> </tr> <tr> <td> <asp:label id="lblid" runat="server" text="id"></asp:label> <asp:textbox id="txtid" runat="server"></asp:textbox> </td> <td> <div id="test"> <asp:image runat="server" id="imgbarcode" width="80px" /> </div> </td> </tr> <tr> <td style="align-items: center; text-align: center" colspan="3"> <input type="button" value="print" onclick="openwin()" /> <%--<asp:button id="btnprint" runat="server" onclientclick="openwin()" text="print" />--%> </td> </tr> </table> </div> </form> </body> </html>
edit:
i got small update i'm not sure if can help. after clicking on print button , getting exception internet explorer has stopped working, got window debug , cancel. when chose debug moved visual studio solution again , although couldn't see useful information when pressed "continue", page showed print dialogue. without "debugging" , "continuing", ie crashes completely.
Comments
Post a Comment