客户端需要安装framework才能够正确通过浏览器访问windows form控件.
具体使用方法请参见:
http://chs.gotdotnet.com/quickstart/winforms/doc/WinFormsAxHosting.aspx

解决方案 »

  1.   

    一般可以通过自定义工具箱,贴加该控件的dll,就可以使用
    或者创建带有object标记的HTML 文档,具体你可以看quickstar
    <object id="simpleControl1"
    classid="http:SimpleControl.dll#Microsoft.Samples.WinForms.Cs.SimpleControl.SimpleControl"
    height="300" width="300" VIEWASTEXT>
    <param name="Text" value="Simple Control">
    </object>
    classid 有两个令人感兴趣的部分:指向控件库的路径和控件的完全限定名,这两者由#号分隔开
    但如上所说,客户端也得安装.net framework
      

  2.   

    兄弟,那是在winform中嵌入webform吧,通过mdi的窗口,反过来了。。
      

  3.   

    难道是我眼花了:)
    Using Windows Forms Controls in Internet Explorer
    http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx
      

  4.   

    各位大哥,我已经看过了上面的网页,但是还不是很明白,能举个简单的例子来说说嘛?例如我在Web Form中引用Windows Form中的ListBox,我在“引用”那里添加了System.windows.forms,在工具栏那里添加了“自定义工具”
    Com组件:Microsoft Forms 2.0 listbox,接下来应该怎样做呢?
      

  5.   

    新建  项目  windows控件库  
    添加一个用户控件,在上面放一个winform的ListBox,做其他你需要的设置
    编译为dll
    到web项目中,在aspx页中加入<object id= classid=……
      

  6.   

    这个时候客户端要装.net framework嘛!
      

  7.   

    当然得装,不过不用注册,让我们祈祷支持.net framework的Windows版本早日推出吧:)
      

  8.   

    支持.net framework的Windows版本的推出就是.net盛放之时!
      

  9.   

    好象是只能在WinForm里才能用工具箱这种方式,WebForm里就手写一下Classid吧
      

  10.   

    各位大哥,我在Codebehind代码中引用该控件时出以下错误:
    异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
    请各位帮忙!
      

  11.   

    在设计Web Form的页面上是可以看到该控件的,但是运行的时候就出现下面的错误:请问是什么原因呢?应该怎样解决阿?
    分析器错误信息: GUID 应包含带 4 个短划线的 32 位数 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。
      

  12.   

    这是控件的代码:
    Imports System
    Imports System.Windows.Forms
    Namespace web_control
        Public Class UserControl1
            Inherits System.Windows.Forms.UserControl#Region " Windows 窗体设计器生成的代码 "        Public Sub New()
                MyBase.New()            '该调用是 Windows 窗体设计器所必需的。
                InitializeComponent()            '在 InitializeComponent() 调用之后添加任何初始化        End Sub        'UserControl1 重写 dispose 以清理组件列表。
            Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                If disposing Then
                    If Not (components Is Nothing) Then
                        components.Dispose()
                    End If
                End If
                MyBase.Dispose(disposing)
            End Sub        'Windows 窗体设计器所必需的
            Private components As System.ComponentModel.IContainer        '注意:以下过程是 Windows 窗体设计器所必需的
            '可以使用 Windows 窗体设计器修改此过程。
            '不要使用代码编辑器修改它。
            Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
            <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
                Me.ListBox1 = New System.Windows.Forms.ListBox()
                Me.SuspendLayout()
                '
                'ListBox1
                '
                Me.ListBox1.HorizontalExtent = 5000
                Me.ListBox1.HorizontalScrollbar = True
                Me.ListBox1.ItemHeight = 12
                Me.ListBox1.Name = "ListBox1"
                Me.ListBox1.Size = New System.Drawing.Size(144, 76)
                Me.ListBox1.TabIndex = 0
                '
                'UserControl1
                '
                Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListBox1})
                Me.Name = "UserControl1"
                Me.Size = New System.Drawing.Size(152, 80)
                Me.ResumeLayout(False)        End Sub#End Region        Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                ListBox1.Items.Insert(0, "asdfasfasdfsdafasdfasfasdfsdfasdfasdfasdfa")
                ListBox1.Items.Insert(1, "sdfsdafsadfsdafksafjasfkjfksjfjasfjsadjfkjsdfjsddf")
            End Sub
        End Class
    End Namespace
      

  13.   

    这是Web Form页面的代码:
    <%@ Page Language="vb" debug="true" AutoEventWireup="false" src="test.aspx.vb" Codebehind="test.aspx.vb" Inherits="_192._168._10._202.test" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>test</title>
    <META content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
    <META content="Visual Basic 7.0" name="CODE_LANGUAGE">
    <META content="JavaScript" name="vs_defaultClientScript">
    <META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <BODY MS_POSITIONING="GridLayout">
    <FORM id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <OBJECT id="listbox1" style="Z-INDEX: 101; LEFT: 0px; WIDTH: 500px; POSITION: absolute; TOP: 0px; HEIGHT: 100px" classid="http:\bin\web_listbox.dll#System.Windows.Forms.UserControl.UserControl1" VIEWASTEXT>
    </OBJECT>
    </FONT></FONT></FORM>
    </BODY>
    </HTML>这是Codebehind的代码:
    Imports System
    Imports System.Windows
    Imports System.Windows.Forms.Form
    Public Class test
        Inherits System.Web.UI.Page
        Protected WithEvents listbox1 As System.Windows.Forms.ListBox
    #Region " Web 窗体设计器生成的代码 "    '该调用是 Web 窗体设计器所必需的。
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
            '不要使用代码编辑器修改它。
            InitializeComponent()
        End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '在此处放置初始化页的用户代码
            ListBox1.Items.Insert(0, "asdfsdafsdfasdfdsafsdfasdfsdafasdfasfsdfasdfasdfasdfasdfasdfasdfasfsdafsadfsadfsdafsdafasdfasdfsd")
            ListBox1.Items.Insert(1, "sfshfsjfjsafjsadff")
            ListBox1.Items.Insert(2, "sdafsdafsadfjsdafjsjfjasdfkasjfkjasdfjkasdjfsjafjasfjasjfjasdkfjsajsadfjask")
            ListBox1.HorizontalExtent = 50000
            ListBox1.HorizontalScrollbar = True
        End SubEnd Class请大哥真的要帮小弟这个忙!
      

  14.   

    我试了试,控件是没问题
    我生成了一个,也可以添加到Web页上
    不知道这句话你是怎么加上去的
    Protected WithEvents listbox1 As System.Windows.Forms.ListBox
    我估计问题的原因应该是这样
    这个控件并不是runat=server的,因而不能在CodeBehind里调用
    但可以用脚本,这是quickstart的原话:若要获取对控件的编程访问,可以针对该控件编写脚本。
    它的例子也仅仅是用脚本控制
    其实你要实现什么交互功能,完全可以在设计控件时给控件加上,WinForm里总比WebForm要好使用吧:)
      

  15.   

    只能通过脚本语言和win control进行交互