⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplerotator3.vb

📁 asp.net技术内幕的书配源码
💻 VB
字号:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Collections

Namespace myControls

' Declare Custom Control Builder
Public Class SimpleRotator3ControlBuilder : Inherits ControlBuilder
  Public Overrides Function GetChildControlType( TagName As String, Attributes As IDictionary ) As Type
    If TagName = "RotatorItem3"
      Return GetType( RotatorItem3 )
    End If
    Return Nothing
  End Function
End Class


' Declare SimpleRotator
<ControlBuilderAttribute(GetType( SimpleRotator3ControlBuilder))> _
Public Class SimpleRotator3: Inherits Control

  Public Items As New ArrayList()

  ' Exclude Everything but RotatorItem controls
  Protected Overrides Sub AddParsedSubObject( Obj As Object )
    If ( TypeOf Obj Is RotatorItem3 )
      Items.Add(Obj)
    End If
  End Sub

  Protected Overrides Sub Render( objTextWriter As HtmlTextWriter)
    Dim objRandom As New Random
    Dim intRanIndex As Integer
    Dim objSelectedItem As RotatorItem3

    If Items.Count > 0 Then
      intRanIndex = objRandom.Next( Items.Count )
      objSelectedItem = CType( Items( intRanIndex ), RotatorItem3 )
      objTextWriter.Write( objSelectedItem.Text )
    End If
  End Sub
End Class

' Declare Rotator Item
Public Class RotatorItem3 : Inherits Control
 Public Text As String
End Class

End Namespace

⌨️ 快捷键说明

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