Working in Source and Split Views to Build a One-Page Web Application - The aspx code for the Future Value form
(Page 4 of 4 )
Figure 2-12 presents the aspx code for the Future Value form that has been developed thus far (except for the Page and Doctype directives, which you’ll learn more about in chapter 5). For now, though, please note that the code for the title that’s displayed in the web browser is between the <head> tags, along with the code for the style classes that are used by the form, and the code for the form design is between the <div> tags.
Within the <div> tags, I’ve highlighted the code for the HTML image control and the code for the six web server controls. If you study this code, you can see how the properties are set for each of these controls. For instance, you can see that I set the Width properties of the button controls to 100 pixels so they are both the same width. You can also see that I set the width of the drop-down list to 106 pixels, even though it appears to be the same width as the text boxes, which are 100 pixels wide. My point is that the sizing properties in the aspx code aren’t always consistent, so you often have to fiddle with these properties to get the design the way you want it.
Before I go on, I want to point out that when you drag an image from the Solution Explorer, an Accessibility Properties dialog box is displayed. This is a new feature of Visual Studio 2008 that lets you set two properties for the HTML image control. First, it lets you set the Alternate Text property (Alt), which specifies the text that’s displayed if for some reason the image can’t be displayed. Because the version of HTML that Visual Studio 2008 uses requires this property, you’ll want to be sure to enter a value for it.
Second, it lets you specify the Long Description property (LongDesc), which provides a Uniform Resource Indicator (URI) to a more extensive description of the image. A URI can be the address of a web page (a URL) or a name that identifies a resource or a unit of information (a URN, or Uniform Resource Name). The Long Description property isn’t required, and in most cases you’ll leave it blank.
The aspx code for the Future Value form
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Chapter 02: Future Value</title>
<style type="text/css">
.style1
{
color: #0000FF;
font-size: x-large;
font-weight: bold;
}
.style2
{
width: 140px;
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="Murach" src="Images/MurachLogo.jpg"
style="width: 150px; height: 65px" /><br /><br />
<span class="style1">401K Future Value Calculator</span><br /><br />
<table>
<tr>
<td class="style2">Monthly investment</td>
<td><asp:DropDownList ID="ddlMonthlyInvestment"
runat="server" Width="106px"></asp:DropDownList></td>
</tr>
<tr>
<td class="style2">Annual interest rate</td>
<td><asp:TextBox ID="txtInterestRate" runat="server"
Width="100px">6.0</asp:TextBox></td>
</tr>
<tr>
<td class="style2">Number of years</td>
<td><asp:TextBox ID="txtYears" runat="server"
Width="100px">10</asp:TextBox></td>
</tr>
<tr>
<td class="style2">Future value</td>
<td><asp:Label ID="lblFutureValue" runat="server"
style="font-weight: 700"></asp:Label></td>
</tr>
<tr>
<td class="style2"></td>
<td></td>
</tr>
<tr>
<td class="style2"><asp:Button ID="btnCalculate" runat="server"
Text="Calculate" Width="100px" /></td>
<td><asp:Button ID="btnClear" runat="server"
Text="Clear" Width="100px" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
--------------------------------------------Figure 2-12 The aspx code for the Future Value form
Please check back tomorrow for the continuation of this article.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
|
This article is an excerpt from chapter two of Murach's ASP.NET 3.5 Web Programming with VB 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774472). Check it out today at your favorite bookstore. Buy this book now.
|
|