Prev | Current Page 301 | Next

Rob Cameron and Dale Michalk

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

Our
second step as before is to check it for a null value to ensure that we actually need to invoke it.
The invocation code on the delegate is the same as we used previously with our event in the
TextBox demonstrations. We invoke the delegate using function call syntax with the name of
the delegate. At this point, our Click event is ready to go??”all we need to do is raise it when a
postback occurs.
CHAPTER 5 ?–  SERVER CONTROL EVEN TS 211
Command Events and Event Bubbling
The second event exposed by our SuperButton control is a command event. The command
event is a design pattern borrowed from the controls in the System.Web.UI.WebControls namespace
that makes event handling in list controls easier.
One example for this scenario is the DataGrid control, which can have buttons embedded
in a column for edit and delete operations. The buttons activate edit or delete functionality
respectively in the DataGrid control, as long as the command events exposed by these buttons
have the correct CommandName property in the CommandEventArgs class as part of the event. If the
button is set with a CommandName of "Delete", it kicks off delete activity. If the button is set with
a CommandName of "Edit", it starts edit functions in the DataGrid control.


Pages:
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313