Events in Custom Controls and Sub Classes

R

Reiner Max

Hello i try do this.

Class DemoBase
Public Delegate Sub DemoItemEventHandler(ByVal sender As Object, ByVal e _
As DemoItemEventArgs)

Public Event ItemCreated(ByVal e As DemoItemEventArgs)

Protected Sub OnItemCreated(ByVal e As DemoItemEventArgs)
RaiseEvent ItemCreated(e)
End Sub
End Class

So now I like to fire the event ItemCreated from this class

Class DemoItems
Function createDemoItems()
.............................
e.Control = td
OnItemCreated(e)
End Function
End Class

then I access this event from my aspx page

Sub DemoBuilder1_ItemCreated(ByVal sender As Object, ByVal e As
DemoBuilder.DemoItemEventArgs) Handles DemoBuilder1.ItemCreated
End Sub

My reason for this way is i can't access events in the class DemoItems
from my aspx page.

Thanks for help.

Max
 
J

John Saunders

Reiner Max said:
Hello i try do this.

Class DemoBase
Public Delegate Sub DemoItemEventHandler(ByVal sender As Object, ByVal e _
As DemoItemEventArgs)

Public Event ItemCreated(ByVal e As DemoItemEventArgs)

First of all, you want:

Public Event ItemCreated As DemoItemEventHandler

Protected Sub OnItemCreated(ByVal e As DemoItemEventArgs)
RaiseEvent ItemCreated(e)
End Sub
End Class

So now I like to fire the event ItemCreated from this class

Class DemoItems

Second, you need

Public Class DemoItems
Inherits DemoBase

Public Function createDemoItems() ' Get into the habit of specifying
accessability
.............................
e.Control = td
OnItemCreated(e)
End Function
End Class

then I access this event from my aspx page

Sub DemoBuilder1_ItemCreated(ByVal sender As Object, ByVal e As
DemoBuilder.DemoItemEventArgs) Handles DemoBuilder1.ItemCreated
End Sub

My reason for this way is i can't access events in the class DemoItems
from my aspx page.

Exactly what error do you see or what problem do you have?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top