|
Page 2 of 2
.
.
Creating a Shopping cart application with Personalization features:
A shopping cart application has to have two classes—Cart and Product. The Cart derives from System.Collections.Generic.List class and Product is a business object prototype with some attributes. Both classes must be marked as Serializable.
1. Create a Website project and add an Application_code directory to the Web site.
2. Right click on this directory and select “Add New Item…” and select class.
3. Name the class file Cart.cs and click Add.
4. Note that a new class file has been created for your project.
5. Enter the following code in the Cart.class file.
Click here to view sample code
6. Now create another class file called Product.cs and enter the following code in it.
Click here to view sample code
7. Now create a web.config file and enter the following code.
< personalization >
< profile >
< add name="Cart" type="Cart" SerializeAs="Xml" / >
< / profile >
< / personalization >
8. An objectDataSource control will now have to be used to access the basket. Open a .aspx file and enter the following code to use the shopping cart. The page will contain a GridViewControl and a DetailsView control. The former will help users show, edit and delete the contents of the cart and the latter will help adding of new items.
Click here to view sample code
9. The design view of the Shopping cart application would look as under:

10. Now create a CartManager class and type in the following code
Click here to view sample code
11. Save all and click F5 to execute.
In this section of the tutorial we have seen how to use personalization to store the profile of the user and also to save the features personalized by users. Complex features and data structures can also be stored by users with personalization as we have seen in the shopping cart application above. In the next section we shall look at Themes and skins which are closely associated with personalization and is often used with it.
Trackback(0)

|