Home All Groups Group Topic Archive Search About
Author
4 Apr 2006 9:25 AM
Arturo Buonanni
Hello,

I'm writing a web app in wich I'm using some Web User Controls. Now I
want these controls to have some basic properties so I've defined my
own class that inherits from System.Web.UI.UserControl, defined some
properties and some code and made my actual Web User Controls inherits
from my class.

In my class I've also defined a public event but this event is not
available to the containers of the web user controls that inherits
from this class.

This is how my base user control class is defined:

<Serializable()> Public Class myContext
    Public CurrentContext As String
    Public Content As String
    Public Description As String
    Public Tag As Object
    Public ParentContext As myContext

    Public Sub New()
        {...init here...}
    End Sub
End Class

Public Class myUserControl
    Inherits System.Web.UI.UserControl

    Public mContext As New myContext
    Public Event OnContextSetB(ByVal mCont As myContext)

    Protected Sub SetContextA(ByVal mCont As myContext)
        {...some code here...}
        RaiseEvent OnContextSetB(mCont)
    End Sub



Hope someone can help.

Thanks.

Author
4 Apr 2006 3:23 PM
CaffieneRush@gmail.com
The subclass cannot raise baseclass' events.
http://msdn2.microsoft.com/en-US/library/0ecakwbz.aspx

But you should be able to handle the base class' events and so the
event is available in a sense.
'An example using your example code.
Public Class mySubUserControl
    Inherits myUserControl

    Public Sub OnSubSetB(mCont As myContext) Handles
MyBase.OnContextSetB
        'Handle base class event here.
    End Sub

    'You can also handle base class' event by overriding the base
class' handler for that event - but that base handler will need to be
declared Overridable.
    Protected Overrides Sub SetContextA(mCont As myContext)
        'Handle base class event here.
    End Sub

End Class
Author
5 Apr 2006 9:58 AM
Arturo Buonanni
Thanks for your reply.

So to "Raise" my base class events I've to "bubble" them up through my
child class.

Am I right?

On 4 Apr 2006 08:23:42 -0700, "CaffieneR***@gmail.com"
<CaffieneR***@gmail.com> wrote:

Show quoteHide quote
>The subclass cannot raise baseclass' events.
>http://msdn2.microsoft.com/en-US/library/0ecakwbz.aspx
>
>But you should be able to handle the base class' events and so the
>event is available in a sense.
>'An example using your example code.
>Public Class mySubUserControl
>    Inherits myUserControl
>
>    Public Sub OnSubSetB(mCont As myContext) Handles
>MyBase.OnContextSetB
>        'Handle base class event here.
>    End Sub
>
>    'You can also handle base class' event by overriding the base
>class' handler for that event - but that base handler will need to be
>declared Overridable.
>    Protected Overrides Sub SetContextA(mCont As myContext)
>        'Handle base class event here.
>    End Sub
>
>End Class