login.vb

来自「asp.net技术内幕的书配源码」· VB 代码 · 共 61 行

VB
61
字号
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace myControls

Public Class Login
Inherits Control
Implements INamingContainer

Public Property Username As String
Get
  Me.EnsureChildControls()
  Return CType( Controls( 2 ), TextBox ).Text
End Get
Set
  Me.EnsureChildControls()
  CType( Controls( 2 ), TextBox ).Text = Value
End Set
End Property

Public Property Password As String
Get
  Me.EnsureChildControls()
  Return CType( Controls( 5 ), TextBox ).Text
End Get
Set
  Me.EnsureChildControls()
  CType( Controls( 5 ), TextBox ).Text = Value
End Set
End Property


Protected Overrides Sub CreateChildControls()
  Me.Controls.Add( New LiteralControl( "<div style=""border: 5px " & _
    "inset #cccccc;background-color:#eeeeee;width:50%;padding:10px"">" ) )

  ' Add Username
  Me.Controls.Add( New LiteralControl( "<b>Username:</b> " ) )
  Me.Controls.Add( New TextBox )
  Me.Controls.Add( New LiteralControl( "<p>" ) )

  ' Add Password
  Dim txtPass As New TextBox
  Me.Controls.Add( New LiteralControl( "<b>Password:</b> " ) )
  txtPass.TextMode = TextBoxMode.Password
  Me.Controls.Add( txtPass )
  Me.Controls.Add( New LiteralControl( "<p>" ) )

  ' Add Submit Button
  Dim btnButton As New Button
  btnButton.Text = "Login!"
  Me.Controls.Add( btnButton )
  Me.Controls.Add( New LiteralControl( "</div>" ) )
End Sub

End Class

End Namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?