Click here to Skip to main content
13,092,862 members (74,315 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Good day all!!!

I have been trying to create a windows form control to host in a webpage. Code below:

using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace WindowsFormsControlLibrary2
    public partial class UserControl1 : UserControl
        public UserControl1()
        public void SendMessage(string msg)
            _lblMessage.Text = msg;

HTML file looks like this. Code below:

<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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!!");               


  <h1>Windows Form Control:</h1> 
<object id="MyWinControl" classid="http://localhost/WindowsFormsControlLibrary2.dll#WindowsFormsControlLibrary2.UserControl1" height="100" width="300" VIEWASTEXT></object>
<input type="button"  önclick="SendMessageToWinControl()" value="Send Message" />


I'm putting both the html and dll files in my wwwroot folder. But I'm not seeing the control. If I click on the "SendMessageToWinControl" button, while firebug is open, it gives me the following error:

Object doesn't support property or method SendMessage;
test.html, line 13 character 6

Even when I copy the code from:
winform control hosting to webform[^]

It's not working. I'm using VS2010 C#4.0
Posted 1-Mar-13 0:41am
Updated 1-Mar-13 0:43am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 1 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100