Actually, I managed to find a moment to prepare an example
Partial Class WebUserControl
Inherits System.Web.UI.UserControl
Protected Sub btn_Click(byval sender as Object, byval e as EventArgs)
Handles btn.Click
Dim e As New SubmitedEventArgs()
e.Time = DateTime.Now
e.Type = txtType.Text
e.Name = txtName.Text
OnSubmitted(e)
End Sub
Public Event Submitted As SubmitedEventHandler
Protected Overridable Sub OnSubmitted( _
ByVal e As SubmitedEventArgs)
RaiseEvent Submitted(Me, e)
End Sub
End Class
Public Class SubmitedEventArgs
Inherits EventArgs
Private _time As DateTime
Public Property Time() As DateTime
Get
Return _time
End Get
Set(ByVal value As DateTime)
_time = value
End Set
End Property
Private _name As String
Public Property Name() As String
Get
Return IIf(_name Is Nothing, String.Empty, _name)
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _type As String
Public Property Type() As String
Get
Return IIf(_name Is Nothing, String.Empty, _type)
End Get
Set(ByVal value As String)
_type = value
End Set
End Property
End Class
Public Delegate Sub SubmitedEventHandler( _
ByVal sender As Object, _
ByVal e As SubmitedEventArgs)
--
Milosz
"Milosz Skalecki [MCAD]" wrote:
> Howdy,
>
> http://www.ondotnet.com/pub/a/dotnet...x1.html?page=4
>
> --
> Milosz
>
>
> "shapper" wrote:
>
> > Hello,
> >
> > I am creating a custom control and I need to define a custom event
> > with its own arguments.
> >
> > I would like to use the ASP.NET standard way to do this, i.e:
> >
> > Private Sub MyCustomControl_Submited(ByVal sender As Object, ByVal
> > e As MyCustomControlEventArgs) Handles mccTest.Submited
> > ...
> > End Sub
> >
> > Where "e" contains the arguments.
> >
> > I created the following:
> >
> > ' SubmitedEventArgs
> > Public Class SubmitedEventArgs
> > Inherits EventArgs
> >
> > Private _Name As String
> > Public Property Name() As String
> > Get
> > Return _Name
> > End Get
> > Set(ByVal value As String)
> > _Name = value
> > End Set
> > End Property ' Name
> >
> > Public Sub New(ByVal name As String)
> > Me.Name = name
> > End Sub ' New
> >
> > End Class
> >
> > And an handler:
> >
> > ' SubmitedEventHandler
> > Public Class SubmitedEventHandler
> >
> > Public Delegate Sub SubmitedEventHandler(ByVal sender As Object,
> > ByVal e As SubmitedEventArgs)
> >
> > End Class
> >
> > Is this right?
> >
> > And how can make my Custom Control to define, use and raise this
> > event?
> >
> > Thanks,
> >
> > Miguel
> >