Inside ASP.NET 2.0
ASP.NET 2.0 is Microsoft's latest Web development platform. Although ASP.NET has some similarities with an earlier Web programming technology named Active Server Pages (ASP), ASP.NET has been completely redesigned based on the.NET Framework. The design component of ASP.NET is Visual Web Developer, which you use to create and manage Internet user interfaces, commonly called Web pages or (in a more comprehensive sense) Web sites.
NOTE
In programming books, you'll sometimes see Web pages referred to as Web forms and Web sites referred to as Web applications, but those terms are less prevalent in the Visual Studio 2005 documentation.
By using Visual Web Developer, you can create a Web site that displays a user interface, processes data, and provides many of the commands and features that a standard application for Microsoft Windows might offer. However, the Web site you create is viewed in a Web browser such as Internet Explorer or Netscape Navigator, and it is typically stored on one or more Web servers, which use Microsoft Internet Information Services to display the correct Web pages and handle most of the computing tasks required by your Web site. (In Visual Studio 2005, Web sites can also be located and run on a local computer that does not require Internet Information Services, giving you more options for development and deployment.) This distributed strategy allows your Web sites to potentially run on a wide range of Internet-based or stand-alone computers—wherever your users and their rich data sources are located.
To create a Web site in Visual Studio 2005, you click the New Web Site command on the File menu, and then use the Visual Web Developer to build one or more Web pages that will collectively represent your Web site. Each Web page consists of two pieces:
A Web Forms page, which contains HTML and controls to create the user interface.
A code-behind file, which is a code module that contains program code that “stands behind” the Web Forms page.
(This division is conceptually much like the Windows forms you've been creating in Visual Basic—there's a user interface component and a code module component.) The code for both of these components can be stored in a single .aspx file, but typically the Web Forms page code is stored in an .aspx file, and the code-behind file is stored in an .aspx.vb file. The following illustration shows a conceptual view of how an ASP.NET Web site stored on a server is displayed in a Web browser:
In addition to Web pages, Web sites can contain code modules (.vb files), HTML pages (.htm files), configuration information (a Web.config file), global Web application information (a Global.asax file), and other components. You can use the Web Page Designer and Solution Explorer to switch back and forth between these components quickly and efficiently.
Web Pages vs. Windows Forms
What are the important differences between Web pages and Windows forms? To begin with, Web pages offer a slightly different programming paradigm than Windows forms. Whereas Windows forms use a Windows application window as the primary user interface for a program, a Web site presents information to the user via one or more Web pages with supporting program code. These pages are viewed through a Web browser, and you can create them by using the Web Page Designer.
Like a Windows form, a Web page can include text, graphic images, buttons, list boxes, and other objects that are used to provide information, process input, or display output. However, the basic set of controls you use to create a Web page is not the set on the Common Controls tab of the Toolbox. Instead, ASP.NET Web sites must use controls on one of the tabs in the Visual Web Developer Toolbox, including Standard, Data, HTML, and many others. Each of the Visual Web Developer controls has its own unique methods, properties, and events, and although there are many similarities between these controls and Windows Forms controls, there are also several important differences. For example, Visual Studio DataGridView control is called GridView in Visual Web Developer and has different properties and methods.
Many Web page controls are server controls, meaning that they run on the Web server. Server controls can be identified on a Web page by the small green icon that appears in the upper-left corner of the control at design time. HTML controls (located in the HTML tab of the Visual Web Developer Toolbox) are client controls by default, meaning that they run only within the end user's browser. An HTML control can be configured as a server control by right-clicking the control in the Web Page Designer and clicking Run As Server Control, or by setting its Runat attribute to Server. For now, however, you simply need to know that you can use server controls, HTML controls, or a combination of both in your Web site projects.
Server Controls
Server controls are more capable than HTML controls and function in many ways like the Windows Forms controls. Indeed, many of the server controls have the same names as the Windows Forms controls and offer many of the same properties, methods, and events. In addition to simple controls such as Button, TextBox, and Label, more sophisticated controls such as FileUpload, LoginView, and RequiredFieldValidator are provided on a number of tabs in the Toolbox (Visual Studio 2005 has added to the list of controls significantly). The following illustration shows some of the server controls in the Visual Web Developer Toolbox:
HTML Controls
The HTML controls are a set of older user interface controls that are supported by most Web browsers and conform closely to the early HTML standards developed for managing user interface elements on a typical Web page. They include Button, Text Field, and Checkbox—useful basic controls for managing information on a Web page that can be represented entirely with HTML code. Indeed, you might recognize these controls if you've coded in HTML before or if you've had some experience with the Visual Basic 6 DHTML Page Designer. However, although they're easy to use and have the advantage of being a “common denominator” for most Web browsers, they're limited by the fact that they have no ability to maintain their own state unless they're configured as server controls. (In other words, the data that they contain will be lost between views of a Web page.) The following illustration shows the HTML controls offered on the HTML tab of the Toolbox in Visual Web Developer: