473,434 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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

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
Jan 12 '08 #1
2 935
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
Jan 14 '08 #2
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
Jan 14 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
3
by: Eric | last post by:
I have built a composite user web control that I want to create dynamically. The form will contain a variable number of these controls and as well some of the contents of the user web control...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
4
by: Otie | last post by:
Hello, I am using the MSFlexGrd Control in VB5. I have 1 fixed row and one fixed column. I am trying to do a sort when the user clicks a column in the FIXED ROW. But when I capture the row...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.