<%@ Page Language="JScript" %>

<script runat="server">

    //*******************************************************
    //
    // The Page_Load event on this page is used to add the
    // identified product to the user's shopping cart, and then immediately
    // redirect to the shoppingcart page (this avoids problems were a user hits 
    // "refresh" and accidentally adds another product to the cart)  
    //    
    // The product to add to the cart is specified using
    // a querystring argument to the page.
    //
    //*******************************************************

    function Page_Load(sender: Object , e: EventArgs) : void {
                      
        if (Request.Params["ProductID"] != null) {
        
            var cart : IBuySpy.ShoppingCartDB = new IBuySpy.ShoppingCartDB();          
            // Obtain current user's shopping cart ID  
            var cartId : String = cart.GetShoppingCartId();
            
            // Add Product Item to Cart 
            cart.AddItem(cartId, Int32.Parse(Request.Params["ProductID"]), 1);
        }  
        
        Response.Redirect("ShoppingCart.aspx");
    }