Microsoft ASP.NET Programming with Microsoft Visual Basic .NET Version 2003 Step By Step

Although this book will focus on building ASP.NET applications with Visual Basic .NET, the development environment you’ll be working in is Visual Studio .NET. Because Visual Studio .NET now supports all of the .NET languages in a single IDE, many of the tasks you’ll learn in this book are applicable to C#, Visual C++, and JScript .NET, as well as to Visual Basic .NET.

Visual Studio .NET Basics

You’ll begin your tour by starting the Visual Studio .NET IDE. Next, you’ll learn about some of the features of the IDE designed to help you get started. You’ll finish this section by learning how to open an ASP.NET Web application project.

Important

The exercises in this chapter require that you have installed at minimum the Visual Basic .NET Standard Edition, as well as the practice files for the book, which you can download from the book’s Web site at http:// www.microsoft.com/mspress/books/6725.asp (under the companion content link). If you have not installed both, please do so now and then return to this chapter.

Start Visual Studio .NET

  1. Click the Start button (shown below), point to All Programs (or Programs in Windows 2000), and then point to Microsoft Visual Studio .NET 2003.

    The icons for Visual Studio .NET will be displayed.

  2. Click the icon for Microsoft Visual Studio .NET 2003.

    The Visual Studio .NET IDE will start. The Start Page is displayed by default whenever you start Visual Studio .NET, and provides links and tools to help you configure the IDE, open recent projects, create new projects, and many other tasks. By default, the IDE will display the Projects tab of the Visual Studio .NET Start Page. This tab allows you to quickly open a recent project or to create a new project. The Online Resources tab allows you to find sample code, access online community resources, find .NET downloads, and more. You’ll see more of this tab in a bit. The My Profile tab of the Start Page, shown in the following illustration, allows you to configure the layout of the tool windows in Visual Studio .NET, as well as the keyboard shortcuts used to accomplish common tasks.

  3. Select the My Profile tab, and then change the main Profile drop- down list from Visual Studio Developer to Visual Basic Developer.

    This will configure the IDE windows and keyboard configuration to match that of Visual Basic 6, as shown in the following illustration, so that experienced Visual Basic developers can more easily find their way around.

  4. Change the Profile drop-down list back to Visual Studio Developer to restore the original settings.

Search for sample code

  1. Click the Online Resources tab.

    By default, the Get Started section will be selected (if it’s not, click Get Started). Here you can search for samples based on the developer profile (Visual Studio, Visual Basic, Visual C++, or Visual C#) and filtered by keyword or type, as shown in the following illustration.

  2. Type ASP.NET in the text box, and then click Go.

    A list of matching samples will be displayed, as shown in the following illustration.

Important

Sample applications and code can be useful tools for learning how to develop applications, including ASP.NET applications. But keep in mind that samples are often designed to illustrate a limited set of specific concepts, and might not always use best practices for security and design. Before using sample code in your applications, be sure that you understand the security and architectural implications of doing so.

Open a Web application project

  1. Switch back to the Projects tab and then click Open Project.

    The Open Project dialog box will be displayed, as shown in the following illustration.

  2. Browse to the location where you installed the practice files (the default is C:\MS Press Books\ASPNETSBS), open the Chapter_01 folder, select the Chapter_01.vbproj file, and then click Open. (Alternatively, you can open all the projects installed with the practice files by selecting the aspnetsbs.sln file located in the aspnetsbs folder.)

    The Chapter_01 project will be loaded. Note that if you open a project originally created with Visual Studio .NET 2002 in Visual Studio .NET 2003, you will be prompted to convert the project file to the newer format. Once this conversion is done, you will not be able to open the project in older versions of Visual Studio .NET.

Note

By default, Windows 2000 and Windows XP hide file extensions for known file types. If this setting is turned on, you will not see the .vbproj and/or .sln extensions to the files mentioned earlier. You can modify this setting in the Windows Explorer Folder Options dialog box. From the Windows Explorer Tools menu, select Folder Options and then click on the View tab. Uncheck the Hide Extensions For Known File Types check box, and then click OK or Apply. The file extensions will now appear in the Open Project dialog box.

Solutions and Projects

Applications in Visual Studio .NET are organized into containers called projects and solutions. Projects are containers for the files associated with a single application type, such as a Web application or control library, while solutions are containers for one or more projects. The projects that make up the sample files for this book are contained in a single solution named aspnetsbs.sln. Solutions are a useful tool for organizing all of the projects associated with a larger application, such as Web applications, and the control projects or component projects associated with them.

Running Web applications is a little different than running Windows applications or console applications. With Windows applications and console applications, running the application in the IDE is as simple as clicking the Start button, shown in the following illustration, on the Visual Studio .NET toolbar. Although you can also run a Web application using this technique, it’s more common to simply browse to the page in the application that you want to test. If you want to run a Web application using the Start button (or by selecting Start from the Debug menu), you need to select a page in your application that will be the start page, or the first page loaded when the application is run. You’ll learn about these techniques in Chapter 14, which covers debugging ASP.NET applications. For now, let’s just test a page by browsing it.

Test a Web Forms page

  1. Load the Chapter_01 project. (If you’ve been following along in the book, you might have already loaded the Chapter_01 project; if so, skip to the next step. If not, return to the previous section, follow the steps to load the project, and then return to this section.)

  2. In the Solution Explorer window, right-click the Welcome.aspx file, and then select View In Browser.

    The Welcome.aspx page, shown in the following illustration, will be loaded into a browser window that is integrated into the IDE. You can browse pages in a Microsoft Internet Explorer external browser window or with browsers other than Internet Explorer by right-clicking a page, selecting Browse With, and then choosing your desired browser and other options.

Категории