经过多次迭代,我有以下代码。这些都不起作用。我是根据直接来自 DYMO 的示例以及此处发布的其他问题得到的。仍然没有任何工作。当我点击按钮时,没有任何反应。
<input id="btnUnitPrint" type="button" value="Print Unit Label" onclick = "printunitLabel()"/><br />
<input id="btnOrderPrint" type="button" value="Print Order Label" onclick = "printorderLabel()"/><br />
<script type="text/javascript">
function printunitLabel() {
var printer = dymo.label.framework.getLabelWriterPrinters()[0].modelName;
printerName = printer.name;
var label = DYMO.Label.Framework.Label.Open("UnitLabel.label");
var company = document.getElementById('<%= txtcompany.Text %>').value;
var customer = document.getElementById('<%= txtcustomer.Text %>').value;
var serial = document.getElementById('<%= txtserial.Text %>').value;
var unit = document.getElementById('<%= txtunit_manuf.Text + txtunit_model.Text %>').value;
var warranty = document.getElementById('<%= ddlWarranty.Text %>').value;
label.SetObjectText("lblcompany", company);
label.SetObjectText("lblcustomer", customer);
label.SetObjectText("lblserial", serial);
label.SetObjectText("lblunit", unit);
label.SetObjectText("txtWarranty", warranty);
label.print(printerName);
}
function printorderLabel() {
var printer = dymo.label.framework.getLabelWriterPrinters()[0].modelName;
printerName = printer.name;
var label = DYMO.Label.Framework.Label.Open("OrderLabel.label");
var company = document.getElementById('<%= txtcompany.Text %>').value;
var customer = document.getElementById('<%= txtcustomer.Text %>').value;
var order = document.getElementById('<%= txtorder_id.Text %>').value;
label.SetObjectText("lblcompany", company);
label.SetObjectText("lblcustomer", customer);
label.SetObjectText("lblorder", order);
label.Print(printer);
label.print(printerName);
}
</script>
更新,此面板包含我希望传递给标签模板的所有变量。
<asp:Panel ID="confirmation_panel" runat="server" Height="457px" Style="margin-right: 0px" Width="1040px" BorderStyle="Double" BorderWidth="2px">
<br />
<table style="width: 469px; height: 385px;">
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblorder_id" runat="server" Text="Order ID:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtorder_id" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_id" runat="server" Text="Unit ID:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_id" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="Label5" runat="server" Text="Company Name:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtcompany" runat="server" ReadOnly="True" Width="231px" Height="22px" NullDisplayText=""></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="Label6" runat="server" Text="Client Name:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtcustomer" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_manuf" runat="server" Text="Unit Manufacturer:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_manuf" runat="server" ReadOnly="True" Width="231px" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblunit_model" runat="server" Text="Unit Model:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtunit_model" runat="server" ReadOnly="True" Width="231px" Height="22px" ForeColor="Red"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblserial" runat="server" Text="Serial Number:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtserial" runat="server" ReadOnly="True" Width="231px" Height="22px" ForeColor="Red"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblWUserial" runat="server" Text="Whole Unit Serial Number:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:TextBox ID="txtWUserial" runat="server" ReadOnly="True" Width="231px" Height="22px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="modal-sm" style="width: 1231px">
<asp:Label ID="lblwarranty" runat="server" Text="Warranty Status:"></asp:Label>
</td>
<td style="height: 34px; width: 326px;">
<asp:DropDownList ID="ddlWarranty" Width="231px" Height="22px" runat="server">
<asp:ListItem>Warranty Expired</asp:ListItem>
<asp:ListItem>Warranty Active</asp:ListItem>
<asp:ListItem>N/A</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</asp:Panel>