1
我有几个下拉列表在应用程序的不同页面。在VB.NET中,如何监听应用程序中任何下拉列表的加载事件?
我需要运行一些功能,当在全局应用程序中加载任何下拉菜单时。
我尝试以下,但不工作:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GetAllDropdowns(Me.Page)
End Sub
Private Sub GetAllDropdowns(ByVal Ctrl As Control)
Dim dd As DropDownList = Nothing
For Each c In Ctrl.Controls
If TypeOf c Is DropDownList Then
dd = DirectCast(c, DropDownList)
AddHandler dd.Load, AddressOf doIt
Else
GetAllDropdowns(c)
End If
Next
End Sub
Private Sub doIt(ByVal sender As Object, ByVal e As EventArgs)
'Do whatever....
End Sub
也许提供一些代码?这个问题无法回答,因为它太宽泛了。 –
plz检查更新的帖子 – Mohamad