Winform控件托管到Webform [英] winform control hosting to webform

查看:70
本文介绍了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..

推荐答案

在此处阅读有关内容(
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆