Sendmessagetowincontrol error - A control type was not specified

Asked

Viewed 85 times

-1

I have a web app that generates barcode tags. In order for a client to be able to print, I need to access the port WITH computer.

I created a project that does this function. But in order for the label to be printed, 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 properly, as follows in the image below:

Imagem do erro

I’ve tried everything, but I can’t make it work. I believe that if the image error goes away, I can make it work.

Below is the code that sends the data to the project and the code that receives the data.

Send the data

    <!DOCTYPE html PUBLIC "-//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>

Receives the 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;
    }
}
  • Can you edit the question by placing the entire HTML? It may be a tag declaration problem.

  • How do I do it Gypsy? I’m new here and I’m not getting to post the whole code.

  • Click edit, just below the question.

  • Ready Gypsy, I put all the HTML code on the page.

1 answer

0

The attribute onload inside <body> is using being increasingly discouraged. The updated use would look something like this:

<head runat="server">
    <title>Impressão de Etiqueta</title>
    ...
    <script type="text/javascript"> 

        window.onload = function() {
            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>
  • Certain Gypsy, but that’s not the problem I’m having. I have this same Thread in another forum. See here: http://forums.asp.net/p/1987478/5700180.aspx?Re+Error+in+SendMessageToWinControl+A+control+type+was+not+specified It’s a problem I’ve never had before. It’s really hard to solve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.