HTML and CSS Reference
ShoppingCartEntities db = new ShoppingCartEntities();
foreach (string p in products)
Order order = new Order();
order.OrderId = orderId;
order.ProductName = p;
order.Qty = 1;
return "Order with " + products.Length.ToString() +
" products has been added!";
The PlaceOrder() web method puts an order in the Orders table. The method accepts an array of
strings that represents product names. Notice how $.ajax() passes the products parameter in JSON
format. Upon successful completion of the web method, the success handler function displays an alert to
the end user.
To test the drag-and-drop behavior, run the web form and try dragging a product on the shopping
bag. Figure 9-8 shows a sample run of the web form.
Figure 9-8. Sample run of the Shopping Cart web form
Notice how the product being dragged (Mouse) is shown with less opacity and how the shopping bag
is highlighted. If you click the Place Order button, the selected products are saved in the database.