0
我有一個面板可以在asp.net中打印。我已經嘗試了很多java腳本代碼,但所有的時候我都會遇到內部html錯誤。以下是代碼。 錯誤代碼Microsoft JScript運行時錯誤:無法獲取屬性'innerHTML'的值:對象爲空或未定義
Microsoft JScript runtime error: Unable to get value of the property 'innerHTML': object is null or undefined
按鈕代碼
<asp:Button ID="Savebutton" runat="server" OnClick="Button1_Click" OnClientClick="return PrintPanel();"/>
Java腳本代碼
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function() {
printWindow.print();
}, 500);
return false;
}
我想股利打印
<div id="printdiv" class="printable" runat="server">
<asp:Panel ID="pnlContents" runat="server">
<asp:Label ID="Label9" runat="server" Text="Medical Record No"></asp:Label>
<asp:Label ID="MRNLBLp" runat="server"></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text="Patient Name"></asp:Label>
<asp:Label ID="Namelblp" runat="server"></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text="Visit Date"></asp:Label>
<asp:Label ID="visitdatelblp" runat="server"></asp:Label>
<br />
<asp:Label ID="Label10" runat="server" Text="Symptoms"></asp:Label>
<asp:Label ID="symptomlblp" runat="server"></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text="Test Prescribed"></asp:Label>
<asp:Label ID="testlblp" runat="server"></asp:Label>
</asp:Panel>
</div>
我該如何取代它才能使其工作。 –
非常感謝 –