Building a Component Library


All the application logic for the e-commerce application was pushed out of the pages and into a separate component library. Placing as much of your application logic as possible into separate components makes it easier to reuse the same methods across multiple pages in your website.

The components are contained in the App_Code folder. The contents of this folder are dynamically compiled. You don't need to perform an explicit Build before using the components in the App_Code folder in your pages.

Note

Components are discussed in Part IV of this book, "Building Components."


The App_Code folder contains the following components:

  • Category Represents a product category. Contains methods for adding, deleting, and editing product categories.

  • Product Represents a product. Contains methods for adding, deleting, and editing products.

  • ShoppingCart Represents a shopping cart. Contains methods for adding and deleting shopping cart items.

  • Order Represents a product order. Contains methods for converting a shopping cart into a product order and retrieving orders.

Each component performs a dual role. Each component represents a particular type of object and it also represents methods for working with objects of that type. For example, the Product component represents a product. It includes all of the product properties such as the product Name and Price properties.

However, the Product component also contains all the methods for interacting with products. For example, it includes a method named SelectByCategoryId() that retrieves all the products contained in a particular category.




ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net