Starting from:

$25

Web Programming-Homework 3 Solved

In this homework, you will design a website that displays book information and allows user to add books into shopping cart.

 

You have to design four web pages (Default.aspx, Login.aspx, BookInfo.aspx, and Cart.aspx) and a class page (Book.cs) that holds book information.

 

Preliminary Work   
1.      Create a web project for the homework.

2.      Download the sample book‐cover images from the web site and put these images into a folder named images in your web folder.

 

Book.cs   
1.      Add a class file named Book.cs into your project (Add New Item, Class). This file will contain information about the books. If you encounter a message which states that this file should be in App_Code folder, then select Yes and let Visual Studio create the App_Code folder for you and put Book.cs file in this folder. After then, you will be able to use the Book class in

                  your application like any other classes of .NET library.

2.      Add member variables to the class Book which are BookID (integer), Title (string), Author (string), Publisher (string), PageNumber (int), and ImageUrl (string).

3.      Define a constructor for the Book class which takes all of its member variables as parameter

(Hint: In Visual Studio, type ctor and press TAB key. This constructs an empty constructor  for the class. After then, change the constructor parameters and implementation). 4. Finally, your Book class should be like this:

 

          public class Book 

{ public int BookID; public string Title; public string Author; public string Publisher; public int PageNumber; public string ImageUrl; 

 

                                        public Book(int BookID, string Title, string Author, string Publisher, int PageNumber, string ImageUrl) 

{ this.BookID = BookID; this.Title = Title; this.Author = Author; this.Publisher = Publisher; this.PageNumber = PageNumber; this.ImageUrl = ImageUrl; 





 

Design of Default.aspx   
When loaded, Default.aspx page should check whether the user is logged in or not. This check should be accomplished by a cookie check. The cookie should contain only the first name and last name of 

 

1

the user. If no such cookie is defined, then Default.aspx should display a message and a link to the Login.aspx as in Fig. 1.

 

  

 

Fig. 1    – Default.aspx when user is not logged in. 

  

Fig. 2 – Login.aspx page 

 

Desig   n of Login.aspx
Login.aspx is very simple web page; it contains only two textboxes for first name and last name, and a Login button as in Fig. 2. There will be no password check. Any user that completes this form will be considered as a logged in user.

When the Login button is clicked , first name and last name will be written into a cookie named UserInfo for one month and the page will be redirected to Default.aspx and Default.aspx will display user info on the left and a list of books on the right as in Fig. 3. The information about the  books is as the following:

 

Book 

ID 
Title 

 
Author 

 
Publisher 

 
Page Number 
1
ASP.NET 3.5 Unleashed
Stephen Walther
Sams
1920
2
ASP.NET Ev olution
Dan Kent
Sams
384
3  
Mastering Web Develop ment with Microsoft Visual Studio 2005
John Pa ul Mueller

 
Sams

 
848

 
4

 

 
Beginning A SP.NET 2.0

 

 
Chris Hart, John Kau fman,

Dave Su ssman, and Chris

Ullman
Wrox

 

 
792

 

 
5

 

 
Beginning A SP.NET 3.5 in C# 2008:

From Novice to Professional, Secon d Edition
Matthe w MacDonal d

 

 
Apress

 

 
954

 

 
 Table 1 – Book info 

  

Fig. 3 – De fault.aspx page after user is logged in 

 

Default.aspx should display a link to Cart.aspx and a Logout button on the left. When the Logout button is clicked, the UserInfo cookie should be remove d and Fig. 1 should be di splayed. 

 

Default.aspx should display the titles of the books on the right with a link on each one. Each link should navigate to BookInfo.aspx with query string named id (e.g. BookInfo.aspx?id=5).

 

When Default.aspx page is first loaded, it should create five Book objects and put all them in to the Session state.

    

 

3

Desig  n of BookInfo.aspx
When a book title is clicked in D efault.aspx, the information about the book should be displayed in BookInfo.aspx page as in Fig. 4. Book ID should be taken from query string with name id.

 

  

 

Fig. 4 – Bo okInfo.aspx p age with a vali d book id 

 

If BookInfo.aspx is requested without any query string or the book ID does not exist, then it should display an appropriate message as in Figures 5 and 6.

 

  

More products