I am using
- Visual Studio 2012
- .NET Framework 4.5
- Visual Basic 2012 (VB 11.0)
I have the web user control ascx page: MyControl.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyControl.ascx.vb" Inherits="MyControl" %>
<asp:Button runat="server" ID="MyButton" OnClick="MyButton_Click" />
I have a web user control code behind: MyControl.ascx.vb
Public Class MyControl
Inherits System.Web.UI.UserControl
Public Event MyClick As EventHandler
Protected Sub MyButton_Click(sender as Object, e as EventArgs) Handles MyButton.Click
RaiseEvent MyClick(sender, e)
End Sub
End Class
Then I have a page which consumes the user control: MyPage.aspx
<%@ Register Src="UserControls/MyControl.ascx" TagPrefix="ucMyControl" TagName="MyControl" %>
<div>
<ucMyControl:MyControl runat="server" ID="UcMyControl" OnMyClick="UcMyControl_MyClick" />
</div>
When I select <Create New Event> from the intellesence as shown in the picture below

The generated UcMyControl_MyClick does not contain the sender as Object, e as EventArgs parameters. See below:
Protected Sub UcMyControl_MyClick()
End Sub
What I expect is to have the EventHandler arguments created whith the event like this:
Protected Sub UcMyControl_MyClick(sender As Object, e As EventArgs)
End Sub
I am new to ASP.NET and Web User Controls. I have searched extensively for this issue to no avail. I have done the following in the MyControl.ascx.vb file
1.
Public Delegate Sub MyControlEventHandler(sender as Object, e as EventArgs)
Public Event MyClick as MyControlEventHandler
2.
Public Event MyClick as EventHandler(Of EventArgs)
3.
Public Event MyClick(ByVal sender As Object, ByVal e As EventArgs)
Related