1. Open DepartmentsList.ascx in Source View and add the FooterStyle element, like this:
<FooterTemplate>
»
<a href="AmazonProducts.aspx"
class='<%# Request.AppRelativeCurrentExecutionFilePath ==
"~/AmazonProducts.aspx" ? "DepartmentSelected" : "DepartmentUnselected" %>' >
Amazon Balloons </a>
«
</FooterTemplate>
<FooterStyle CssClass="DepartmentListContent" />
</asp:DataList>
2. Add a new Web User Control to your UserControls folder, named AmazonProductsList.ascx.
3. While AmazonProductsList.ascx is in Source View, add this bit of code to it:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile=
"AmazonProductsList.ascx.cs"
Inherits="AmazonProductsList" %>
<asp:DataList ID="list" runat="server" RepeatColumns="2"
EnableViewState="False">
<ItemTemplate>
<table height="100" cellpadding="0" align="left">
<tr>
<td valign="top" align="center" width="110">
<img src='<%# Eval("ProductImageUrl") %>' border="0" />
</td>
<td valign="top" width="250">
<span class="ProductDescription">
<%# Eval("ProductName") %>
<br />
Price: </span><span class="ProductPrice">
<%# Eval("ProductPrice") %>
<br /><br />
<a target="_blank" href="http://www.amazon.com/exec/obidos/ASIN/
<%# Eval("ASIN") %>/ref=nosim/<%# BalloonShopConfiguration.AssociateId %>">
Buy From Amazon </a>
</span>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
4. Switch to the code-behind file, and complete the Page_Load method with the following code:
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
// fill the DataList with Amazon products. Calling any of // GetAmazonDataWithRest or GetAmazonDataWithSoap should return // the same results
list.DataSource = AmazonAccess.GetAmazonDataWithRest();
list.DataBind();
} }
5. Add a new Web Form to your solution named AmazonProducts.aspx based on the BalloonShop.master Master Page.
6. Open AmazonProducts.aspx in Source View and modify it like this:
<%@ Page Language="C#" MasterPageFile="~/BalloonShop.master"
AutoEventWireup="true" CodeFile="AmazonProducts.aspx.cs" Inherits=
"AmazonProducts" Title="Balloonshop : Balloons from Amazon" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentPlaceHolder"
Runat="Server">
<span class="CatalogTitle">Balloons From Amazon</span>
<br />
<span class="CatalogDescription">Browse these wonderful balloons that Amazon.com offers: </span>
<br />
</asp:Content>
7. Switch AmazonProducts.aspx to Design View and drag the AmazonProductsList.ascx control from solution explorer to the bottom of the page, as shown in Figure 17-6.
Figure 17-6. Designing the Amazon page
How It Works: Displaying Amazon.com Products in BalloonShop
In this exercise, you simply updated BalloonShop to display Amazon.com products by employing the techniques you studied in the first part of the chapter. The new functionality isn’t especially complex, but the possibilities are exciting. When the Buy from Amazon links are clicked, Amazon.com associates that customer and what she purchases to your Associate ID (which is mentioned in the links).
The code-behind file AmazonProductsList.ascx.cs calls AmazonAccess.GetAmazonDataWithRest() to get the data to populate the list of products. This data is read to build the Amazon links to the retrieved products:
<a target="_blank" href="http://www.amazon.com/exec/obidos/ASIN/
<%# Eval("ASIN") %>/ref=nosim/<%# BalloonShopConfiguration.AssociateId %>">
However, you must know that Amazon offers many ways in which you can allow your visitors to buy their products.
If you log in to the Associates page, you’ll see a number of link types you can build and integrate into your web site.
Perhaps the most interesting and powerful is the possibility to create and manage Amazon shopping carts from your C# code, by using the Amazon API. If you’re really into integrating Amazon.com into your web site, you should study the ECS documentation carefully and make the most of it.
Summary
In this chapter, you learned how to access Amazon Web Services using REST and SOAP. You can use the same techniques when accessing any kind of external functionality exposed through these protocols.
Congratulations, you have just finished your journey into learning about building e-commerce web sites with Beginning ASP.NET 2.0 E-Commerce in C# 2005: From Novice to Profes- sional! You have the knowledge to build your own customized solutions that are even more interesting and powerful than what we showed you in this book. We really hope you enjoyed reading this book, and we wish you good luck with your own personal development projects!
643
■ ■ ■
Installing the Software
The good news is that all the software required to follow this book and build the BalloonShop Web Application is freely downloadable from the Internet. This appendix covers the installation process for the following required programs:
• Visual Web Developer 2005 Express Edition
• SQL Server 2005 Express Edition
• SQL Server Express Manager
• IIS 5.x