HomeASP.NET Comment and Order Management for an ASP.NE...
Comment and Order Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website
Welcome to the ninth part of an eleven-part series focused on building an online shopping web site. In this part you will learn to manage both product comments and orders.
Contributed by Xianzhong Zhu Rating: / 11 January 23, 2008
The product comment management functionality is accomplished through the "CommentManage.aspx." Its total functionalities can be listed as follows:
Show the comments in a table form.
Delete comments.
View comments.
Interface
First, let’s take a look at the design-time snapshot for product comment management, as displayed in Figure 33.
Figure 33—the design-time snapshot for product comment management
As you can see from the above figure, only Ajax is leveraged. When the user clicks the "X" ImageButton in the GridView control to delete the selected comment, to give the user a very clear prompt asking whether or not to make the deletion, we use the ASP.NET AJAX Toolkit control namedConfirmButtonExtenderto pop up a dialog to gain this effect. Since the HTML code is very long, we’ll only look at the part directly related to what we're doing, as follows:
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="deleteBtn" ConfirmText="Are you sure to delete the selected items?">
From the above code, you can easily find out how the ConfirmButtonExtendercontrol is attached to the‘X’ ImageButton. Note that one of the benefits to using most of the ASP.NET AJAX Toolkit controls is that they are very easy to follow up, with no programming required.
Since the coding behind is pretty easy to grasp and we still have a long way to travel we don’t plan to delve into this any more but leave this task to the sedulous readers.
This function is accomplished through the "OrderManage.aspx" page. As a whole, the functions can be enumerated as follows:
Display the order in table form.
Submit the order.
View the order.
View the products on the order.
Now, let’s look at the run-time snapshot, as shown in Figure 34.
Figure 34—the run-time snapshot of order management
Here, there is only a GridView control shown to the user with a few links at each line. If he clicks the order number or the "View Product" button he will be redirected to the "ViewOrder.aspx" page to view the detailed information about the order. In fact, there are two states on the "Order State" column, "Unsubmitted" and "Already Submitted." If the "Unsubmitted" state is shown, then a button titled "Submit Order" appears on the "Operation" column. Otherwise, this button is hidden and the "Order State" column is replaced with "Already Submitted" as displayed in Figure 34.
When the "OrderManage.aspx" page is initialized, the related OrderFormdata is bound to GridView "OrderView," i.e. showing the factual order data and its associated state.
When you click the "Submit Order" button on the "Operation" column in Figure 34. the corresponding order will be committed to the server-side database, and at the same time the "Order State" column state changes to "Already Submitted." This is accomplished entirely through the following code.
Response.Write("<script>alert('" + "You have succeeded in committed this order. Please safekeep you data!" + "');</script>");
}
}
Here, we first find the "commit" command via the CommandNameargument of the GridViewCommandEventArgs parameter. Then the commit operation is started by calling the CommitOrderForm member functionof the OrderForm class. And at last, the order data is rebound to display the current state of the order.