网站制作

本类阅读TOP10

·IIS 安装配置全攻略
·用VS.NET打开网上下载的.NET web项目出错的解决办法
·HTML 4.0 语言快速参考
·限制TextArea区的文字输入数量
·如何在网页上实现进度条
·Apache的配置步骤及测试
·谈谈Jesse James Garrett提到的Ajax
·html基础学习笔记(2)
·页面垂直居中的两种方法
·用asp遍历目录下文件的例子

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Asp.net可输入下拉框服务器控件

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站



Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls

'''/*
''' * CBDAspNet - ASP.Net Development Framework
''' * Copyright (C) 2004-2005 Chengdu Binary Digital Tech. Co.,Ltd.
''' *
''' * Company Homepage
''' *    http://www.cbdsystem.com.cn
''' *
''' * File Name: D:\CuteProject\CBDAspNet\CBDWebControls\CBDTextBox\CBDTextBox.vb
''' *
''' * Version:  1.0
''' * Modified: 2005年1月27日 10:00:46
''' *
''' * File Authors:
''' *      Ryan Liu ([email protected])
''' *

Namespace 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 Class

End Namespace



相关文章

相关软件