Maximizing.ASP.dot.NET.Real.World.ObjectOriented.Development [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Maximizing.ASP.dot.NET.Real.World.ObjectOriented.Development [Electronic resources] - نسخه متنی

Jeffrey Putz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Server Controls, Their Events and Event Handlers


Before we get into the many events that the application and your pages will encounter, it's helpful to look at events on a smaller scale. Server controls such as our LinkButton (or Web controls, as they are sometimes called) can have events that let us determine that something happened on a form, and we can write code to handle these events.

Server controls have, at the very least, five events: Init, Load, PreRender, Unload, and Disposed. (Some controls also have a DataBinding event.) These events indicate pretty obvious occurrences in the control's lifecycle, and they're all a part of the System.Web.UI.Control class, the base class for many controls you use all of the time. Some controls also have their own events to respond to changes in the control's state. The Calendar control, for example, has a SelectionChanged event that happens when the user chooses a new date.

When events occur, we may want some kind of code to fire. These blocks of code are event handlers. It's important to understand that events and event handlers are not the same thing. For example, the Page class (which also ultimately inherits from Control) has a Load event and an event handler called OnLoad. Event handlers typically are named by prefacing the event name with "On." Event handlers are "wired" or assigned to an event when the control is created. We'll get to event wiring shortly. Additionally, a number of methods are fired throughout the life of a control that can be overridden by your own derived controls.

These events and event handlers are called on every request for the page, for every control (unless of course the entire page is cached). We'll spend a chapter on this process, but for now, just be aware that these events and event handlers are there.


You're probably wondering at this point how you can write your own events for your own controls. Fear not, we'll get to that in Chapter 9, "Server Controls." For now, let's just stick to handling events.


/ 146