Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing All Base Controls
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00642367
Message ID:
00642778
Views:
18
>in my base class I have this code
>
>protected override void OnClick(System.EventArgs e)
> {
> MessageBox.Show("Base Class");
> }
>
>

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkEventsTutorial.asp
"Events and Inheritance
When creating a general component that can be derived from, what seems to be a problem sometimes arises with events. Since events can only be invoked from within the class that declared them, derived classes cannot directly invoke events declared within the base class. Although this is sometimes what is desired, often it is appropriate to give the derived class the freedom to invoke the event. This is typically done by creating a protected invoking method for the event. By calling this invoking method, derived classes can invoke the event. For even more flexibility, the invoking method is often declared as virtual, which allows the derived class to override it. This allows the derived class to intercept the events that the base class is invoking, possibly doing its own processing of them.
"

Does calling the base event from the derived OnClick work?
protected override void OnClick(System.EventArgs e)
		{
                        base.Onclick(e);
			MessageBox.Show("Base Class");
		}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform