08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

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 3 ■ WEB FORMS WITH <strong>ASP</strong>.<strong>NET</strong> 59<br />

3. ListBox1_SelectIndexChanged<br />

4. ListBox2_SelectIndexChanged<br />

5. Button_Click<br />

6. Page_PreRender<br />

7. Page_Unload<br />

Note that the order in which the SelectionIndexChanged events occur might vary,<br />

depending on the order in which the user clicked them before pressing the button. They<br />

don’t necessarily fire in chronological order, as this list indicates.<br />

Performing Data Binding<br />

Data binding is a vital part of making web applications easy to develop. In short, it<br />

enables us to automatically set properties on a control from the contents of a database or<br />

other data store. It involves little to no coding on the developer’s part. It is a tool provided<br />

by the <strong>ASP</strong>.<strong>NET</strong> Framework. We’ll be going into this very important functionality in more<br />

detail in Chapter 4.<br />

One issue to note is the timing at which the data-binding functionality occurs. Any<br />

data binding that updates the data store via an insert, a delete, or an update will occur<br />

after all the control events are h<strong>and</strong>led, but before the Page_PreRender occurs. Then, after<br />

the PreRender event, the functionality that queries the data store will fire. This ensures<br />

that data isn’t stale, because any functionality on your page that updates the data store<br />

will happen before anything is read from the data store. Therefore, the data on your page<br />

is always up-to-date.<br />

Server Tidies Up Objects<br />

To maintain application scalability, the server sends the results of the page rendering to<br />

the client, <strong>and</strong> in its memory, cleans up everything for a particular session. The server<br />

now “forgets” about the page, <strong>and</strong> control is returned to the browser. Information that is<br />

necessary for the server to “remember” the page again at the next session is stored in<br />

view state, <strong>and</strong> the page is initialized with this information on the next postback.<br />

Pages <strong>and</strong> Controls<br />

Because <strong>ASP</strong>.<strong>NET</strong> is a true object-oriented development API, the page itself is an object<br />

that is accessible to the developer, as are the controls on the page (which are members of

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

Saved successfully!

Ooh no, something went wrong!