Book Image

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

Book Image

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

Overview of this book

Microsoft AJAX Library Essentials is a practical reference for the client-side library of the ASP.NET AJAX Framework 1.0, and a tutorial for the underlying technologies and techniques required to use the library at its full potential. The main goal of this book is to get you comfortable with the Microsoft AJAX Library, a huge set of functions that can be used for developing powerful client-side functionality.Beginning with a hands-on tour of the basic technologies associated with AJAX, JavaScript, XMLHttpRequest, JSON, and the DOM, you'll move on to a crash course in the Microsoft AJAX tools. You will learn, through numerous step-by-step exercises, how to create basic AJAX applications, how the object-based programming model of JavaScript works, and how Microsoft AJAX Library extends this model. You'll understand the architecture of the Microsoft AJAX components, how they all fit together, and exactly what they can do for you. Then you will learn how to use the Microsoft AJAX Library in your web projects, and a detailed case study will walk you through creating your own customized client components. At every stage of your journey, you'll be able to try out examples to illuminate the theory, and consolidate your understanding. In addition to learning about the client and server controls, you'll also see how to handle errors and debug your AJAX applications.To complement your new found skills, the book ends with a visual reference of the Microsoft AJAX Library namespaces and classes, including diagrams and quick explanations for all the classes mentioned in the book, providing an invaluable reference you will turn to again and again.
Table of Contents (14 chapters)
Copyright
Credits
About the Authors
About the Reviewers
Preface

Setting Up Your Environment


In the next few pages we’ll guide you through installing the following softwares, which you’ll need for this book:

  1. 1. IIS (Internet Information Services), which is the Web Server used to serve ASP.NET pages.

  2. 2. Visual Web Developer 2005 Express Edition, which is the tool that you’ll be using to develop your ASP.NET applications.

  3. 3. The ASP.NET AJAX Framework.

Installing IIS

To run ASP.NET web applications, you can use either Visual Web Developer’s integrated Web server (Cassini), or you can use IIS. Theoretically, the most important difference between the two environments are the credentials under which the code runs. Cassini runs with the credentials of the logged in user, while IIS uses a special system account named ASPNET.

Note

If you really want to, you can also run ASP.NET pages using Apache, although we’ve not tested this configuration for the purposes of this book. Read more details at http://weblogs.asp.net/israelio/archive/2005/09/11/424852.aspx .

The two major benefits of using Cassini are:

  • Cassini works on systems that don’t ship with IIS, such as Windows XP Home Edition.

  • Cassini can be used in case you don’t want to use your main IIS Web Server for development purposes.

Even if these advantages don’t convince you, we still recommend using IIS because your application would end up running under an IIS server anyway, so the development environment would more closely resemble the production environment.

IIS is delivered with most versions of server-capable Windows operating systems, including Windows Vista Business, Windows XP Professional, Windows XP Media Center Edition, Windows 2000 Professional, Server, Advanced Server, and Windows Server 2003, but it’s not installed automatically in all versions, which is why it may not be present on your computer.

IIS isn’t available in Windows XP Home Edition, Windows Vista Home Basic, or Windows Vista Home Premium—if you run one of these, you’ll need to rely on Cassini.

Note

The main development tool we’ll use in this book is Visual Web Developer 2005, which works best with IIS 6, which ships with Windows XP. Windows Vista, on the other hand, includes IIS 7, whose default settings aren’t very friendly with Visual Web Developer 2005. This explains that you have more configuration work to do before you’ll be able to run and debug your ASP.NET Web Applications under Windows Vista properly.

To install IIS, simply follow these steps:

  1. 1. In the Control Panel, select Programs and Features (in Windows Vista), or Add or Remove Programs (in Windows XP).

  2. 2. Choose Turn Windows features on or off (in Windows Vista), or Add/Remove Windows Components (in Windows XP). The list of components will become visible within a few seconds.

  3. 3. In the list of components, check Internet Information Services. If running Windows XP, expand the node and make sure that the IIS Frontpage Extensions node is checked.

In Windows Vista, also select the following options (also see Figure 1-4).

  1. 1. Web Management Tools | IIS 6 Management Compatibility node, and its IIS Metabase and IIS 6 configuration compatibility sub-node. (IIS 6 Management Compatbility is required by Visual Web Developer 2005 when connecting to your web site through FrontPage Extensions.)

  2. 2. World Wide Web Services | Application Development Features | ASP.NET node.

  3. 3. Select the World Wide Web Services | Security | Windows Authentication node, which is necessary if you want to run applications in debug mode.

    Figure 1-5 Configuring IIS 7 Options in Windows Vista

  4. 4. Click Next or OK. Windows may prompt you to insert the Windows CD or DVD.

To administer IIS, you use the Internet Information Services (IIS) Manager tool (in Windows Vista) or the Internet Information Services tool (in Windows XP) that you can find in the Administrative Tools menu of the Control Panel.

Installing Visual Web Developer

Install Visual Web Developer 2005 Express Edition following these simple steps:

  1. 1. Go to http://msdn.microsoft.com/vstudio/express/vwd/ .

  2. 2. Click the Download link. You’ll download a file named vwdsetup.exe.

  3. 3. Execute the downloaded file.

  4. 4. Accept the default options. At one point you’ll be asked about installing Microsoft MSDN 2005 Express Edition, which is the product’s documentation. Installing it will do no harm, but you need to be patient, because it’s quite big.

  5. 5. Install the Visual Web Developer Service Pack 1. If you use Windows Vista, you should install the Service Pack 1 for Windows Vista.

  6. 6. The final step involves configuring ASP.NET with IIS. If you’ll be using Cassini or IIS 7, this step is not needed. Start a command-line console (Start | Run | cmd), and type the following commands:

    cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
    aspnet_regiis.exe -i
    

Creating a Folder for Your Project

To keep your hard drive tidy, let’s create a folder that we’ll be using for every exercise in this book. Create a folder named Atlas in an easily accessible place of your hard drive. I’ll assume you’re creating it as C:\Atlas.

Now we need to configure this folder as an IIS virtual directory so that it doesn’t interfere with other applications you may have on your machine. After preparing the Atlas Web Application, the http://localhost/Atlas/ application will be loaded from the C:\Atlas physical folder. If you can’t use IIS, then skip to the “Hello World!” section, a bit later in this chapter.

Because of the interface differences between the IIS 5/6 and IIS 7, separate installation instructions are provided for Windows XP and Windows Vista.

Preparing the Atlas Application in Windows Vista

If you’re running Windows Vista and IIS 7, follow these steps to prepare your Atlas folder.

  1. 1. Open the IIS Manager tool from the Administrative Tools section of the Control Panel.

  2. 2. Find the Default Web Site in the Connections tab, and make sure it’s started. If its status is Stopped, right-click on it and select Start.

  3. 3. Right-click Default Web Site, and select Add Application from the context menu.

  4. 4. Choose Atlas for the alias name, and C:\Atlas for its “physical” path. Then click Select..., choose Classic .NET AppPool, and click OK. (If you don’t choose the Classic .NET AppPool, you won’t be able to debug the project using Visual Web Developer 2005.) In the end, the Add Application dialog should look like Figure 1-6.

    Figure 1-6 Creating the Atlas IIS Application

  5. 5. After clicking OK to close the Add Application dialog, the Atlas virtual directory will show up as a child node under Default Web Site. Select the Atlas node, double-click the Authentication icon, and enable Windows Authentication.

  6. 6. Close the IIS Manager.

Preparing the Atlas Web Application in Windows XP

If you’re running Windows XP, follow these steps to prepare your Atlas folder

  1. 1. Open the Internet Information Services tool from the Administrative Tools section of the Control Panel. Then expand the node for your local computer, then expand the Web Sites node, as shown in Figure 1-7.

    Figure 1-7 Internet Information Services Tool in Windows XP

  2. 2. Make sure that the Default Web Site is running. If its status is Stopped, right-click on it and select Start:

  3. 3. Right-click Default Web Site, and select New | Virtual Directory.

  4. 4. In the wizard that shows up, first click Next, then type Atlas for the name of the Virtual Directory. Then click Next.

  5. 5. Type the full path for the “physical” folder where you’ll save the examples from this book. If you created the folder as suggested, then the path whould be C:\Atlas.

  6. 6. In the next screen, check Read and Run scripts (such as ASP), and click Next.

  7. 7. Click Finish to close the wizard, then close the Internet Information Services applet.