|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
events inheritanceI'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. 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 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
"Cannot have multiple items selected in a DropDownList" Error
How to get ListItemValue and ListItemText from a Combo using SendMessage edit attribute values of a web control just before control rendered to the page (control's Load even checkbox bind with 0 = checked? error using .NET CrystalReportViewer (.NET 1.1 VS.NET 2003) Removing columns from Gridview(2.0) databinding on templatefileds dont work? Problems with dynamically created GridView/DetailsView Rendering a Treeview Control DataGrid item dropdownlist javascript disable GridView XmlDataSource |
|||||||||||||||||||||||