1

我收到了这个错误:

Exception Description : E:\sites\EPER EN\Admin\DB\DataFilter.ascx.vb(144): error BC32022: 'Public Event Click(sender As Object, e As System.EventArgs)' is an event, 
and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.  Source File :   Line : 0

在以下 vb.net 代码中:

submitFilterButton.Click += New EventHandler(AddressOf submitFilterButtonHandler_Click)

这个错误是什么意思 ?

4

1 回答 1

2

如果要以编程方式注册事件处理程序,则必须使用AddHandler::

AddHandler submitFilterButton.Click, AddressOf submitFilterButtonHandler_Click 

您也可以在 aspx 标记上以声明方式添加它(处理程序必须是受保护的/公共的)

OnClick="submitFilterButtonHandler_Click"

或在代码隐藏中通过Handles子句(可以是私有的)

Private Sub submitFilterButtonHandler_Click(sender As System.Object, e As System.EventArgs) Handles submitFilterButton.Click

如何:在 ASP.NET 网页中创建事件处理程序

于 2013-02-25T09:56:55.350 回答