Winform控件托管到Webform [英] winform control hosting to webform
本文介绍了Winform控件托管到Webform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 WindowsControlLibrary
{
[ComVisible(true)]
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public void SendMessage(string msg)
{
_lblMessage.Text = msg;
}
}
}
我已经制作了这个用于将Winform控件托管到网页的dll文件.但是当我托管此页面时,它会提供我已插入html的控件,但显示活动x的空白....
i have made this dll file for hosting winform controls to webpage. but when i host this page it give controls which i have inserted in html but show blank space for active x ....
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="htmlObject.WebForm1" %>
<!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="bin/WindowsControlLibrary.dll#WindowsControlLibrary.UserControl1" width=800 height=300>
<param name="Text" value="Simple Control">
</object>
<br/>
<input type="button" onclick="SendMessageToWinControl()" value="Send Message" />
</body>
</html>
请解决这个问题..
plz solve it..
推荐答案
在此处阅读有关内容( ^ ])
查看以下内容...
使用Internet Explorer.在其他任何浏览器中均不起作用.
在客户端计算机上安装.NET框架.
该站点应包含在浏览器的受信任站点列表中.
应该允许浏览器从(受信任的)站点下载文件.
尝试此操作时,会给客户端带来很多警告,所以建议您阅读一些有关此主题的文章和教程,以更好地理解允许的内容.
Reading about this here (http://codebetter.com/petervanooijen/2007/06/18/including-a-winforms-user-control-in-an-asp-net-web-page/[^] )
check out the following...
Use Internet Explorer. This does not work in any of the other browsers.
Have the .NET framework installed on the client machine.
The site should be included in the trusted sites list of the browser.
The browser should be allowed to download files from the (trusted) site.
There are many caveats for the client when you try this, so I would suggest reading a few articles and tutorials about this topic to gain a better understanding of what is allowed.
这篇关于Winform控件托管到Webform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文