PC Review


Reply
Thread Tools Rate Thread

Control Event. Please, need some help. Thank You.

 
 
shapper
Guest
Posts: n/a
 
      12th Jan 2008
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
 
Reply With Quote
 
 
 
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      14th Jan 2008
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
>

 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      14th Jan 2008
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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system event log, Event ID 7000, Service Control Manager Ed Parker Windows XP Performance 1 20th Nov 2006 12:08 AM
Control where change event does not trigger click event? =?Utf-8?B?c3dvcmRmaXNo?= Microsoft Powerpoint 2 17th Jul 2006 06:21 PM
Pass a form value from a user control to parent control - Event Order issues ab_j@flyingrobot.com Microsoft ASP .NET 0 29th Oct 2004 06:38 PM
Control Exit event kills Button Click Event in Access2002 Forms =?Utf-8?B?TWlrZSBFbGxpb3R0?= Microsoft Access Form Coding 4 20th Oct 2004 05:08 PM
Help: Control lost doesn't raise event after being moved to dynamically loaded user control Thanh Nguyen Microsoft ASP .NET 0 1st Apr 2004 03:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:17 PM.