Workshop


Quiz

1.

Why is the design requirements phase of software development an important one?

2.

How can you add a TextBox Web control to an ASP.NET web page using Visual Web Developer?

3.

Why did we add a Label Web control to our ASP.NET web page's HTML portion?

4.

What will the ASP.NET web page's output be if the user enters invalid characters into the TextBoxes? For example, if under the Mortgage Amount TextBox, the user enters "Sam"?

5.

How do you add an event handler for a Button Web control's Click event with Visual Web Developer?

6.

When using a TextBox Web control, what property is referenced to determine the value entered by the user?

Answers

1.

The design requirements phase outlines the specific features for the software project and also outlines the user interface. It is an important stage because, by enumerating the features, you and your boss and client can easily determine the current progress of the project. Furthermore, there is no ambiguity as to what features should and should not be included.

2.

There are two ways to add a TextBox Web control. First, you can simply click the TextBox Web control from the Toolbox and drag it onto the page. Second, from the Source view, you can manually type in the TextBox's syntax:

<asp:TextBox runat="server" ></asp:TextBox> 


3.

A Label Web control was added to the ASP.NET web page's HTML portion to indicate where the output of the financial calculator would appear.

4.

If the user provides invalid input, a runtime error will occur. Refer to Figure 4.11 for the error message the user will receive.

5.

To add an event handler for a Button Web control's Click event, simply double-click the Button in the Design view that you want to add an event handler for. You can alternatively create the event handler by selecting the appropriate Web control and event items from the two drop-down lists at the top of the source code portion.

6.

The Text property contains the value entered by the user. To reference this property in an ASP.NET web page's source code portion, we can use

TextBoxID.Text 


Exercises

  1. In this hour we saw how to use Visual Web Developer to create an ASP.NET web page with three TextBox Web controls, a Button Web control, and a Label Web control. Using this knowledge, let's create an ASP.NET web page that will prompt the user for his name and age. After the user provides this information and clicks the submit button, the ASP.NET web page will display a message for the user, depending on his age.

    This ASP.NET web page will need to have two TextBox Web controls, a Button Web control, and a Label Web control. Set the TextBox Web controls' ID properties to name and age. The Button Web control should have its Text property set to Click Me. Set the Label Web control's ID property to results and clear out its Text property. Then create an event handler for the Button Web control's Click event. Recall that this is accomplished by simply double-clicking the Button in the designer.

    Now, in the Click event handler, determine what message to display, based on the user's age. The code for this will look like:

    If age.Text < 21 then   results.Text = name.Text & ", you are a youngster!" End If If age.Text >= 21 AND age.Text < 40 then   results.Text = name.Text & ", you are an adult." End If If age.Text >= 40 then   results.Text = name.Text & ", you are over the hill!" End If 

    After you have entered the preceding source code into the Button Web control's Click event handler, save the ASP.NET web page and test it by visiting it through a browser.

  2. For more practice with Visual Web Developer, take a moment to enhance the user interface of the FinancialCalculator.aspx web page we created in this hour. Some suggested enhancements include displaying the TextBox Web control titles in a more appealing font, adding some text at the top of the web page explaining the purpose of the financial calculator, and so on.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

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