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

Create successful ePaper yourself

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

CHAPTER 3 ■ WEB FORMS WITH <strong>ASP</strong>.<strong>NET</strong> 43<br />

Next, be sure to use the Properties window to give your controls some friendly<br />

names. The names used in this example are shown in Table 3-1. You’ll see what they look<br />

like in HTML in Listing 3-3.<br />

Table 3-1. Naming Your HTML Controls<br />

Control<br />

First Number TextBox<br />

Second Number TextBox<br />

First radio button (Add)<br />

Second radio button (Subtract)<br />

Submit button<br />

Result TextBox<br />

Name<br />

txtFirst<br />

txtSecond<br />

optOption<br />

optOption (using the same name groups the radio buttons)<br />

btnSubmit<br />

txtResult<br />

If you aren’t familiar with HTML forms code, a few things may seem a little quirky,<br />

particularly when dealing with the radio buttons. To create a group of radio buttons<br />

where only one is selectable, use the name property <strong>and</strong> set each one to the same value.<br />

So, as you can see in Listing 3-3, each radio button is called optOperation. You distinguish<br />

them from each other using the value property. In this listing, you can see that they contain<br />

the values Add <strong>and</strong> Subtract, respectively.<br />

Listing 3-3. Your HTML Form<br />

<br />

<br />

<br />

<br />

Untitled Page<br />

<br />

<br />

<br />

<br />

First Number &nbsp; &nbsp; &nbsp;<br />

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

Saved successfully!

Ooh no, something went wrong!