|
我從來(lái)沒(méi)有進(jìn)行過(guò)正式的web開(kāi)發(fā),但是我一直喜歡web,所以這篇文章也是我轉(zhuǎn)行web的一個(gè)開(kāi)始吧。或多或少我也參考了幾個(gè)網(wǎng)站的實(shí)現(xiàn)(當(dāng)然了,只是看看大概的功能而已),所以也請(qǐng)大家多多指教。該購(gòu)物車(chē)的功能如下:
1. 通過(guò)ajax實(shí)現(xiàn)添加和刪除車(chē)上的物品。
2. 刪除的物品會(huì)顯示出來(lái),可以重新添加到購(gòu)物車(chē)。
3. 嗯...沒(méi)有了,具體大家接著看吧。
購(gòu)物車(chē)的結(jié)構(gòu)我打算用一個(gè)table來(lái)展示,在UserControl里使用ListView展現(xiàn)購(gòu)物車(chē)的物品(因?yàn)楸绕唇幼址菀拙S護(hù)的多)。具體代碼如下(ShopCartTest.ascx):

1 <ASP:ListView ID="ListView1" runat="server">
2 <LayoutTemplate>
3 <table runat="server" cellpadding='0' cellspacing='0' width='100%'>
4 <tr>
5 <td width='7%' style='height: 30px'>
6 商品編號(hào)
7 td>
8 <td>
9 商品名稱(chēng)
10 td>
11 <td width='10%'>
12 京東價(jià)
13 td>
14 <td width='8%'>
15 返現(xiàn)
16 td>
17 <td width='8%'>
18 贈(zèng)送積分
19 td>
20 <td width='9%'>
21 商品數(shù)量
22 td>
23 <td width='7%'>
24 刪除商品
25 td>
26 tr>
27 <tr runat="server" id="itemPlaceholder" />
28 <tr>
29 <td colspan='7' style='height: 30px'>
30 重量總計(jì):<%= this.GetProductsWeight() %>kg 原始金額:¥307.00元 - 返現(xiàn):¥0.00元<br />
31 <span style='font-size: 14px'><b>商品總金額(不含運(yùn)費(fèi)):<span id='cartBottom_price'>¥307.00span>元b>span>
32 td>
33 tr>
34 table>
35 LayoutTemplate>
36 <ItemTemplate>
37 <tr>
38 <td style='padding: 5px 0 5px 0;'>
39 <%#(Container.DataItem as Product).ID %>
40 td>
41 <td>
42 <a target='_blank' href='http://www.xxx.com/product/<%#(Container.DataItem as Product).ID %>.html'>
43 <%#(Container.DataItem as Product).Name %>a>
44 td>
45 <td>
46 <span>
47 <%#(Container.DataItem as Product).Price %>span>
48 td>
49 <td>
50 <%#(Container.DataItem as Product).BackMoney %>
51 td>
52 <td>
53 <%#(Container.DataItem as Product).Score %>
54 td>
55 <td>
56 <a href='#none' title='減一' onclick="changeCount('-','<%#(Container.DataItem as Product).ID %>','sku');"
57 style='text-decoration: none'>-a><input type='text' id='txt<%#(Container.DataItem as Product).ID %>'
58 name='txtChange<%#(Container.DataItem as Product).ID %>' maxlength='4' style='width: 30px'
59 value='<%#(Container.DataItem as Product).Count %>' /><a href='#none' title='加一'
60 onclick="changeCount('+','<%#(Container.DataItem as Product).ID %>');" style='text-decoration: none'>+a>
61 td>
62 <td>
63 <a href='#none' id='btn_del_173259' onclick="removeProductOnShoppingCart('<%#(Container.DataItem as Product).ID %>',this)">
64 刪除a>
65 td>
66 tr>
67 ItemTemplate>
68 ASP:ListView>
NET技術(shù):淺析購(gòu)物車(chē)的實(shí)現(xiàn),轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。