Deitel & Associates, Inc. Logo

Back to
digg.png delicious.png blinkit.png furl.png
Visual Basic 2005
How to Program, 3/e

© 2005
pages: ~1500
Amazon logo

This is the fourth in a series of four tutorials that introduces ASP.NET 2.0 and Microsoft's Visual Web Developer Express IDE for building Web applications. The Visual Web Developer Express functionality we discuss is also part of the complete Visual Studio 2005. Both Visual Web Developer Express and Visual Studio 2005 are scheduled to be released in November 2005. This series of tutorials is a small part of Chapter 21, ASP.NET, Web Forms and Web Conrols, from our forthcoming book Visual Basic 2005 How to Program, 3/e. Chapter 21 is part of a four chapter sequence on XML, ADO.NET, ASP.NET and Web Services in which we discuss each of these technologies and demonstrate how to build substantial, data driven Web applications.

Part 1 provided a brief introduction to ASP.NET, Web Forms and Web controls. Part 2 discussed simple HTTP transactions that enable client/server interactions on the Web. Part 3 overviewed multitier application architecture. This part (which consists of several subsections that you can link to at the bottom of this page) presents a simple Web Form example, analyzes its parts, shows how it executes, and discusses how to build and deploy the Web Form. The tutorials in this series are intended for students and professionals who are already familiar with Visual Basic .NET programming. These tutorials are intended for students and professionals who are already familiar with Visual Basic .NET programming.

[Note: This series of tutorials is an excerpt (Sections 21.1-21.4) of Chapter 21, ASP.NET, Web Forms and Web Controls, from our forthcoming textbook Visual Basic 2005 How to Program, 3/e. These tutorials may refer to other chapters or sections of the book that are not included here. Permission Information: Deitel, Harvey M. and Paul J., Visual Basic 2005 How to Program, ©2005. Electronically reproduced by permission of Pearson Education, Inc., Upper Saddle River, New Jersey.]

Part 4: 21.4 Creating and Running a Simple Web Form Example
In this section, we present our first example, which displays the Web server's time of day in a browser window. When run, this program displays the text A Simple Web Form Example, followed by the Web server's time. As mentioned previously, the program consists of two related files-an ASPX file (Fig. 21.4) and a Visual Basic code-behind file
Fig. 21.4 ASPX file that displays the Web server's time. 
1   <%-- Fig. 21.4: WebTime.aspx --%>
2   <%-- A page that displays the current time in a Label. --%>
3   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="WebTime.aspx.vb"
4      Inherits="WebTime" EnableSessionState="False" %>                     
6   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
7       "">
9   <html xmlns="">
10      <head runat="server">
11         <title>A Simple Web Form Example</title>
12      </head>
13      <body>
14         <form id="form1" runat="server">
15            <div>
16               <h2>Current time on the Web server:</h2>
17               <p>
18                  <asp:Label ID="timeLabel" runat="server" BackColor="Black"
19                     Font-Size="XX-Large" ForeColor="Yellow"               
20                     EnableViewState="False"></asp:Label>                  
21               </p>
22            </div>
23         </form>
24      </body>
25  </html>
(Fig. 21.5). We display the markup, code and output first; then we carefully guide you through the step-by-step process of creating this program. [Note: The markup in Fig. 21.4 and other ASPX file listings in this chapter is the same as the markup that appears in Visual Web Developer, but we have reformatted the markup for presentation purposes to make the code more readable.]
Visual Web Developer generates all of the markup shown in Fig. 21.4 when you set the Web page's title, type text in the Web Form, drag a Label onto the Web Form and set the properties of the page's text and the Label. We demonstrate how to perform these steps in the sections that follow. (Continue to "Examining an ASPX File".)

Tutorials in This Series:
ASP.NET Tutorial Part 1: Introduction to ASP.NET
ASP.NET Tutorial Part 2: Simple HTTP Transactions
ASP.NET Tutorial Part 3: Multitier Application Architecture
ASP.NET Tutorial Part 4: Creating and Running a Simple Web Form Example (You are here.)

Tutorial Index