13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8: Control Events and Event Handlers 205Figure 8-4 The Change event generates two new messages.previous chapters you have seen event handling associated with different web controls andeven with Web forms. However, these sections focus exclusively on the events and how tobest use them.Button Command EventsOne of the more interesting events you can use with buttons is OnCommand. The Button webcontrols have two <strong>com</strong>mand-related properties: CommandName and CommandArgument.You can assign the OnCommand event any name you want, and that name will be used asthe function name in the C# portion of the application. For all intents and purposes, theOnCommand event works just like an OnClick event.Both the CommandName and CommandArgument are recognized in the Propertieswindow when you are creating an application. The CommandName is a unique name thatcan be associated with the <strong>com</strong>mand, and the CommandArgument is a string containingwhatever <strong>com</strong>mand argument you want to include. Both are generally included when youuse the OnCommand event.Changing the Event Handler ParametersTo get the <strong>com</strong>mand information, you have to change the event handling functionparameters you’ve used up to this point. Also, you will need to add another namespace.In the entire automatic C# code rendering you may have done in creating your

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!