Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I created a windows form user control dll. The control has a button and and a picturebox. I added it to my .aspx page using this:

XML
<object id="MyWinControl1" height="200" classid="http:WindowsFormsControlLibrary1.dll#WindowsFormsControlLibrary1.UserControl1" VIEWASTEXT> </object>


I put it in between my body tag.
In design view I get this error:
a control type was not specified or the specified type could not be found

What am I doing wrong? Do I need to put more information?

[OPs Answer moved to here]

This is my code:
UserControl1.cs:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsControlLibrary1
{
    [ComVisible(true)]
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
        public void SendMessage(string msg)
        {
            lblMessage.Text = msg;
        }

    }
}

HTMLPage1.htm
XML
<!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>
  <title>Windows Form Control Test Page</title>
  <script type="text/javascript">
      function SendMessageToWinControl() {
          var winCtrl = document.getElementById("MyWinControl");
          winCtrl.SendMessage("Message sent from the HTML page!!");
      }
  </script>
 </head>
 <body>
  <h1>Windows Form Control:</h1>
  <object id="MyWinControl" classid="http:WindowsControlLibrary1.dll#WindowsControlLibrary1.UserControl1"
          height="100" width="300" VIEWASTEXT/>
  <br/><br/>
  <input type="button" onclick="SendMessageToWinControl()" value="Send Message" />
 </body>
</html>

When I look at the HTMLPage1.htm in design view. Where it is suppose to show the control it says:
a control type was not specified or the specified type could not be found

and i don't see the button that is suppose to show.
When I view HTMLPage1.htm in the browser I see a red X where my control is suppose to be at. And I don't see the button that is suppose to show.
Posted
Updated 25-Feb-11 7:55am
v2

1 solution

I have never tried to do this myself, but I did find this little tutorial that claims it can be done.
Hosting a Windows Form Control in a web page

I found it with this google search.
 
Share this answer
 
v2
Comments
Espen Harlinn 25-Feb-11 6:24am    
Good links, my 5
flomm 25-Feb-11 12:17pm    
I still get the same error on the design page. and I see an x on the html page where the control is suppose to be. I have googled as well and everything I try, my control never shows. All I see is a red x.
someone123456789 13-Mar-12 12:58pm    
Did you ever solve this problem or not?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900