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> 41<br />

Listing 3-2. Viewing the Form in a Browser<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

You can see that the <strong>ASP</strong>.<strong>NET</strong> runtime recognized that it encountered the tag<br />

by saying runat="server", <strong>and</strong> realized that the tag was a server control, not a raw HTML<br />

tag. Therefore, it generated the required form, defaulting the method to HTTP-POST<br />

<strong>and</strong> specifying itself (Default.aspx) as the agent (via the action attribute) to h<strong>and</strong>le the<br />

form feedback.<br />

An HTML Forms Example in <strong>ASP</strong>.<strong>NET</strong><br />

The following example contains an <strong>ASP</strong>.<strong>NET</strong> form, which is a server-side control that<br />

generates a client-side form, as well as a number of client-side form elements. If this is<br />

confusing, don’t worry—it will soon become second nature. I’ve deliberately chosen this<br />

complex scenario to demonstrate how <strong>ASP</strong>.<strong>NET</strong> makes it easy for you to mix <strong>and</strong> match<br />

server-side <strong>and</strong> client-side functionality to make your work as easy as possible.<br />

First, use VWDE to create a new web site. Open the default page that is created for<br />

you for editing, <strong>and</strong> select Design view within the Visual Studio UI.<br />

Now take a look at the Toolbox for the HTML controls. It should look something like<br />

Figure 3-1. Remember that you are going to use the <strong>ASP</strong>.<strong>NET</strong> HTML controls, which have<br />

a programming interface similar to the actual HTML controls they represent. (This is in<br />

contrast to the st<strong>and</strong>ard <strong>ASP</strong>.<strong>NET</strong> controls, which ultimately generate HTML but have a<br />

more robust programming interface.)

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

Saved successfully!

Ooh no, something went wrong!