O'Reilly logo

ASP.NET by Example by Steven A. Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Raising Events

Sometimes you will want to raise events of your own from within your controls. For example, a validation control might raise an event to let its parent control know that it found an invalid element. Although not necessary for many kinds of controls and a bit more advanced, custom events can be a powerful tool. A simple example of raising an event and handling it from an ASP.NET page is really all that we have room for in this chapter, but it should give you an idea of how this works and get you started if you need to build an event-raising control of your own.

Just to keep things simple, we're going to add an event to our HelloPerson class that we used earlier in the chapter. We have decided that if this control's PersonName property ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required