网上找到一段 Asp.net可输入下拉框服务器控件的代码,如下:Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControlsNamespace CBDAspNet.WebControls.HTML    ''' <summary>
    ''' 可输入的下拉框控件
    ''' </summary>
    <ToolboxData("<{0}:TextBox runat=""server"" />")> _
    Public Class TextBox
        Inherits System.Web.UI.WebControls.TextBox        Private _values As Hashtable        Public _DropDownList As DropDownList        Public Sub New()
            _DropDownList = New DropDownList
            _values = New Hashtable
        End Sub        Public Property Values() As Hashtable
            Get
                Return _values
            End Get
            Set(ByVal Value As Hashtable)
                _values = Value
            End Set
        End Property        Protected Overrides Sub Render(ByVal Output As System.Web.UI.HtmlTextWriter)            Dim iWidth As Integer = MyBase.Width.Value
            If iWidth = 0 Then
                iWidth = 102
                'MyBase.Width = Unit.Parse("102px")
            End If            Dim sWidth As Integer = iWidth + 16
            Dim spanWidth As Integer = sWidth - 18            Output.Write("<div style=""POSITION:relative"">")
            Output.Write("<span style=""MARGIN-LEFT:" & spanWidth & "px;OVERFLOW:hidden;WIDTH:18px"">")            _DropDownList.Width = Unit.Parse(sWidth & "px")
            _DropDownList.Style.Add("MARGIN-LEFT", "-" & spanWidth & "px")
            _DropDownList.Attributes.Add("onchange", "this.parentNode.nextSibling.value=this.value")            If _values.Count > 0 Then
                For Each key As String In _values.Keys
                    Dim item As ListItem = New ListItem
                    item.Value = key
                    item.Text = _values(key)
                    _DropDownList.Items.Add(item)
                Next
            End If
            ''如果只有一个可选内容
            If _DropDownList.Items.Count = 1 Then
                Dim item As ListItem = New ListItem
                item.Value = ""
                item.Text = " "
                _DropDownList.Items.Add(item)
                _DropDownList.SelectedIndex = 1
            End If
            _DropDownList.RenderControl(Output)            Output.Write("</span>")            MyBase.Style.Clear()
            MyBase.Width = Unit.Parse(iWidth & "px")
            MyBase.Style.Add("left", "0px")
            MyBase.Style.Add("POSITION", "absolute")            MyBase.Render(Output)            Output.Write("</div>")        End Sub    End ClassEnd Namespace
 问题是:我怎么用在我的工程中,将它当做常规的服务器控件使用一样! (关键是这一步啊)
    取值 绑定数据源等操作,怎么写代码!谢谢了 :)  在线等

解决方案 »

  1.   

    还有 我工程是用C#语言的 这个是VB.NET 怎么搞啊????
      

  2.   

    先把它编译成dll,然后再添加它的引用,就可以像常规的服务器控件使用了。
      

  3.   

    同上,先在vs里面进行编译,然后把该dll拷贝到引用其的程序的bin目录下!,接着在在项目资源管理器该项目下右击引用,定位到dll所在位置加入dll即可!放心,和语言无关