Introduction to Web Forms

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 5.  Beginning Web Forms


Web forms are very similar to traditional HTML forms. The difference is that Web forms are server-based, meaning you create the user elements on the server. The server has complete knowledge of what the interface looks like, what it can do, what data it expects, and so on.

graphics/newterm_icon.gif

On the server, you create objects known as server controls that represent pieces of the UI. Unlike HTML form elements, these objects are completely controllable they have properties, events, and methods that you can manipulate. As soon as the client requests the page, ASP.NET converts these controls into HTML, which renders perfectly in the browser. Figure 5.2 illustrates the process.

Figure 5.2. With Web forms, the server knows what the form looks like and what it can do.

graphics/05fig02.gif

Through the client-side script that ASP.NET generates automatically, these controls alert the server whenever something happens, such as a button click. When an event does occur, the client-side script posts information to the server, often without the user's knowledge. Thus, the server is constantly notified of what's happening on the client, and the server and client are tied together.

Note

This showcases the event-driven model at work. However, remember that underneath it all, ASP.NET still relies on request/response to send information back and forth. Using the event-driven model on top of the request/ response model provides a more intuitive environment for application development.


Also, since the server created the controls, it can remember what was entered in each control. Recall from Day 2, "Building ASP.NET Pages," that ASP.NET uses hidden form fields to remember the viewstate of each control and can update them accordingly.

Web forms make our lives much easier by telling the server what's going on in the user interface. Imagine trying to drive blindfolded while a passenger yelled out "Left!" or "Right!" at the appropriate times. Using traditional HTML forms was similar they didn't tell the server what was going on, but they occasionally supplied data. How could the server control the application properly?

Web forms lift the "blindfold." The server can see everything that's going on and properly "drive" the program.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net