Using Visual Web Developer to Build Pages in ASP.NET 2.0
In this hour, we will cover
- Creating new websites and web pages
- Opening existing websites
- Customizing the editor through Visual Web Developer’s Options menu
- Using techniques for laying out HTML content through the Design view
- Moving and resizing the assorted windows
- Accessing help through the installed documentation
In the preceding hour we looked at the ASP.NET programming model, noting how ASP.NET pages are composed of an HTML portion and a source code portion. Recall that the HTML portion of an ASP.NET web page consists of static HTML markup and Web control syntax; the source code portion, separated out into its own file, is implemented as a class with various event handlers.
In the past two hours, you got a cursory look at Visual Web Developer, the development environment we’ll be using throughout this book to build ASP.NET pages. In Hour 1, "Getting Started with ASP.NET 2.0," we installed Visual Web Developer and received a quick tour of its features. In the preceding hour we delved a bit deeper into Visual Web Developer’s interface, looking at how to create a new ASP.NET website and how to use the WYSIWYG Design view, the HTML Source view, and the source code editor.
Because we’ll be using Visual Web Developer extensively throughout this book, it behooves us to take a moment to fully explore this editor. Visual Web Developer is a sophisticated and powerful programming editor, with a bevy of features and capabilities. As with any profession, it’s important to have a solid grasp of the tools at your disposal.
Creating a New Website
When you start Visual Web Developer, you will typically want to do one of two things: either create a new website or open an existing website. A website is a collection of resources: static and dynamic web pages, graphic files, style sheets, configuration files, and so on. In addition to various files, a website may contain subdirectories, each of which may contain its own set of files and further subdirectories. A website is akin to a folder on your personal computer: It’s a repository for files and subfolders.
To create a new website with Visual Web Developer, go to the File menu and select New Web Site or simply click the New Web Site icon in the Toolbar. Either of these actions will bring up the New Web Site dialog box, shown in Figure 3.1.
Figure 3.1 Create a new website from the New Web Site dialog box.
Choosing a Website Template
When creating a new website, you can choose among a number of available templates. For example, there’s the ASP.NET Web Site template, the ASP.NET Web Service template, the Personal Web Site Starter Kit template, and an Empty Web Site template. Regardless of what template is selected, a website will be created; the differences among the templates is what default files the template includes with the website. For example, in the preceding hour we saw that creating a new website using the ASP.NET Web Site template creates a website with an App_Data folder and three files: Default.aspx, Default.aspx.vb, and web.config. Creating a website using the Empty Web Site template will create the website but will not add any default folders or files.
Although there is an array of website templates to choose from, all of the examples in this book will be created using the ASP.NET Web Site template.
Specifying the Website’s Location
Websites can be located either on your personal computer or on a remote computer. Typically, personal computers do not double as web servers; that is, chances are the personal computer on which you’re working right now does not host websites. Rather, you use your PC for your own ends—surfing the web, checking email, playing games, and so on. Publicly available websites are often hosted through web-hosting companies, which offer always-on computers with a persistent connection to the Internet. These computers’ sole purpose is to host a website; they have web server software running on them and essentially sit around and wait for incoming requests. Upon receiving a request for a web page, they render the page and return the resulting markup to the requesting browser.
Often developers place a website on their own personal computer during the building and testing phases. The site won’t be accessible over the Internet, but that’s okay because the site is not yet ready for the public. When a functional site is complete, though, it can be moved to a remote web-hosting company so that the site can be accessed by anyone with an Internet connection. However, you can opt to create a new site on a remote computer from the get-go. All you need is an account with a web-hosting company.
If you opt to host the website on your local computer you can host it in, potentially, one of two ways:
Through the file system—With this approach, you provide a directory on your hard drive that serves as the website’s root directory. All of the site’s associated files and folders will be placed in that specified directory.
Through IIS, Microsoft’s Web server—If your personal computer has Internet Information Services (IIS) installed, you can host the website locally through IIS. IIS can be installed on Windows XP Professional and Windows 2003 Server; it is not able to be installed on Windows XP Home edition.
If you want to host the site locally, from the Location drop-down list, select File System. Next, click the Browse button to the right of the Location drop-down list. This will bring up the Choose Location dialog box shown in Figure 3.2.
Figure 3.2 Choose the location where your website will reside.
The left column in the Choose Location dialog box lists the various locations the website can be saved.
To host the website on a remote computer, select either the HTTP or FTP options for location and specify the HTTP or FTP address. For the FTP settings, you’ll need to provide the FTP server, port, directory, and username/password, if anonymous access is not allowed. Similarly, if you choose to use the HTTP setting when attempting to create the website, you’ll be prompted for a username and password. Contact your web-hosting company for information on whether you should use HTTP or FTP access and what settings you’ll need to use in order to connect.
All of the websites throughout this book will be created on the local file system.
Choosing the Source Code Programming Language
The setting chosen in the Language drop-down list specifies the programming language of your ASP.NET web pages’ source code portions. Two options are available: Visual Basic and Visual C#. As discussed in the preceding hour, the Visual Basic language will be used for the examples throughout this book.
To gain practice creating websites in Visual Web Developer, go ahead and create a new website using the ASP.NET Web Site template, the File System location with the website in a directory of your choice, and with the Language set to Visual Basic. As we saw in the preceding hour, this will create a website with an App_Data folder, a Default.aspx ASP.NET page (with a corresponding Default.aspx.vb file), and a configuration file, web.config. These files are listed in the Solution Explorer, which you can find in the upper-right corner. (If you do not see the Solution Explorer, go to the View menu and choose the Solution Explorer option.)