62,268
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsControlLibrary1
{
[ComVisible(true)]
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public void SendMessage(string msg){
_lblMessage.Text = msg;
}
}
}
<!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>
Console.WriteLine("求大神现身..........");