开发者

Embedding a C# Control Into a Website

开发者 https://www.devze.com 2023-04-02 17:43 出处:网络
How do I embed a C# form control into an HTML page? I found this tutorial: http://weblogs.asp.net/spano/archive/2007/09/19/hosting-a-windows-form-control-in-a-web-page.aspx

How do I embed a C# form control into an HTML page?

I found this tutorial: http://weblogs.asp.net/spano/archive/2007/09/19/hosting-a-windows-form-control-in-a-web-page.aspx and tried to follow it... But it didn't work... Here is my code: HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD X开发者_如何学GoHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<object classid="http://ctrl.dll#ctrl.ctr" height="100" width="100" VIEWASTEXT/>
</body>
</html>

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 ctrl
{
    [ComVisible(true)]
    public partial class ctr : UserControl
    {
        public ctr()
        {
            InitializeComponent();
        }
    }
}
//on the design view there is a button; dimensions are 100*100

Note that all (both) files are in the same folder.

Does anyone know what is wrong with this? (I tested this in IE and Chrome)

0

精彩评论

暂无评论...
验证码 换一张
取 消