SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 279 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

Instead of
calling the event directly, a good design pattern followed by all the prebuilt server controls in
ASP.NET is to add a virtual protected method that invokes the event with a prefix of On attached to
the name of the method. This provides an additional level of abstraction that allows controls
that derive from a base control to easily override the event-raising mechanism to run additional
business logic or suppress event invocation altogether. The following code shows an OnClick
protected method used to provide access to the Click event of class:
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
Click(this, e);
}
The first thing the protected method does is check to see if any client methods have registered
themselves with the Click event instance. The event field will have a null value if no
clients have registered a method onto the delegate??™s invocation list. If clients have subscribed
to the Click event with a method having a matching signature, the event field will contain an
object reference to a delegate that maintains the invocation list of all registered delegates. The
OnClick routine next invokes the event using the function call syntax along with the name of
the event. The parameters passed in are a reference to the control raising the event and the
event arguments passed into the routine.


Pages:
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6