I have a web application that generates barcode label. In order for a client to print, I need to access the COM port on the computer.
I created a project that does this function. But for the label to print, I need my application to pass the parameters to the new project.
When I execute the function that should do this, an error appears: 0x800a01b6 - Erro em tempo de execução do JavaScript: O objeto não dá suporte para a propriedade ou método: SendMessage()
.
I also noticed that the control I created is not working right, as follows in the image below:
I'vetriedeverything,butIcannotgetittowork.Ibelievethatiftheimageerrordisappears,Icanmakeitwork.
Belowisthecodethatsendsthedatatotheprojectandthecodethatreceivesthedata.
Senddata
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Impressão de Etiqueta</title>
<script type="text/javascript">
function SendMessageToWinControl()
{
var winCtrl = document.getElementById("PrintBarcode");
winCtrl.SendMessage(document.form1.HiddenField1.value,
document.form1.HiddenField2.value,
document.form1.HiddenField3.value,
document.form1.HiddenField4.value,
document.form1.HiddenField5.value);
}
</script>
</head>
<body onload = "SendMessageToWinControl()" >
<form id="form1" runat="server">
<object id="PrintBarcode"
classid="http:codbarra.dll#codbarra.UserControl1"
name="PrintBarcode" height="150" width="360" VIEWASTEXT>
</object>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HiddenField2" runat="server" />
<asp:HiddenField ID="HiddenField3" runat="server" />
<asp:HiddenField ID="HiddenField4" runat="server" />
<asp:HiddenField ID="HiddenField5" runat="server" />
</form>
</body>
</html>
Receive data
[ComVisible(true)]
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public void SendMessage(string paciente, string nome, string amostra, string cliente, string pedido)
{
c19tbl20.Text = cliente;
c1tbl374.Text = pedido;
c2tbl375.Text = amostra;
c1tbl372.Text = paciente;
c2tbl372.Text = nome;
}
}