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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

204<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>Figure 8-3 The Init events generate text for the web controls}protected void LabelEvent(object sender, EventArgs e){Label1.Text = "Hello Mr. Label";}Those few events and two web controls tell a very big event story. When you test theapplication, you should first see the page shown in Figure 8-3.Both the TextBox and Label web controls contain text that is generated by the Initevent. The Load and Init events are part of the life cycle an <strong>ASP</strong>.<strong>NET</strong> page goes throughwhen it launches. For all intents and purposes, you will find very few differences betweenusing initialization and Load events because they both occur when the page first appears.The only user event is changing the text in the TextBox from “Original” to anythingelse—the event is a Change event. As soon as you make a change, the TextBox and Labelchange as shown in Figure 8-4.The events in this example are mostly automatic, occurring as the page loads. Theonly event that fires otherwise is when the user makes a change to the original contentsof the TextBox and presses ENTER. Pressing TAB will not fire the event, so if you want itto work effectively with users, you need to clearly specify to press ENTER when they haveentered their information.Now that you have a general idea of setting up events and event handlers, the nextseveral sections look at various web controls dealing with different kinds of events andat handling those events. You will be familiar with some of the event issues because in

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

Saved successfully!

Ooh no, something went wrong!