Events in Custom Controls and Sub Classes

Discussion in 'ASP .Net Building Controls' started by Reiner Max, Jun 15, 2004.

  1. Reiner Max

    Reiner Max Guest

    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
    Reiner Max, Jun 15, 2004
    #1
    1. Advertising

  2. Reiner Max" <> wrote in message
    news:18kyh3b03mk4l$.13os3md5xmyrn$...
    > 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?
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 15, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    2
    Views:
    882
  2. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,019
    Lawrence D'Oliveiro
    May 20, 2011
  3. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    354
    Chris
    Aug 30, 2005
  4. Morten Guldager

    classes and sub classes?

    Morten Guldager, Apr 9, 2013, in forum: Python
    Replies:
    7
    Views:
    148
    Neil Cerutti
    Apr 15, 2013
  5. Robert Kern

    Re: classes and sub classes?

    Robert Kern, Apr 9, 2013, in forum: Python
    Replies:
    0
    Views:
    111
    Robert Kern
    Apr 9, 2013
Loading...

Share This Page