刚开始接触asp:Wizard的时候摸不着头脑,不知道这个是什么东东,因为之前自己没有用过这个控件,算自己长见识了。故今天把它记录下来。
View Code
1 <asp:Wizard ID="wzdCheckOut" runat="server" DisplaySideBar="False" OnActiveStepChanged="wzdCheckOut_ActiveStepChanged"
2 OnFinishButtonClick="wzdCheckOut_FinishButtonClick" SkinID="wzdCheckOut">
3 <WizardSteps>
4
5 <asp:WizardStep ID="wzdStep1" runat="server" Title="Billing Address">
6 <asp:Panel ID="panFicusStep1" runat="server" DefaultButton="StartNextButton">
7 <PetShopControl:AddressForm ID="billingForm" runat="server"/><!--billForm-->
8 <table border="0" cellpadding="0" cellspacing="0" class="checkoutButtonBg" width="100%">
9 <tr>
10 <td></td>
11 <td align="right">
12 <asp:LinkButton ID="StartNextButton" runat="server"
13 CommandName="MoveNext" CssClass="continue" OnClick="StartNextButton_Click">Next
14 </asp:LinkButton></td>
15 </tr>
16 </table>
17 </asp:Panel>
18 </asp:WizardStep>
19 <asp:WizardStep ID="wzdStep2" runat="server" Title="Shipping Address">
20 <asp:Panel ID="panFicusStep2" runat="server" DefaultButton="StepNextButton">
21 <div class="checkOutLabel">
22 <asp:CheckBox ID="chkShipToBilling" runat="server" AutoPostBack="True" OnCheckedChanged="chkShipToBilling_CheckedChanged"
23 Text="Ship to billing address"/></div>
24 <PetShopControl:AddressForm ID="shippingForm" runat="server"/>
25 <table border="0" cellpadding="0" cellspacing="0" class="checkoutButtonBg" width="100%">
26 <tr>
27 <td align="left"><asp:LinkButton ID="StepPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"
28 CssClass="back">Previous</asp:LinkButton></td><td align="right"><asp:LinkButton ID="StepNextButton" runat="server" CommandName="MoveNext" CssClass="continue">Next</asp:LinkButton></td>
29 </tr>
30 </table>
31 </asp:Panel>
32 </asp:WizardStep>
33 <asp:WizardStep ID="wzdStep3" runat="server" Title="Payment Information">
34 <asp:Panel ID="panFicusStep3" runat="server" DefaultButton="StepNextButton2">
35 <table border="0" cellpadding="0" cellspacing="0">
36 <tr>
37 <td class="label">Credit Card Number<br />
38 <asp:TextBox ID="txtCCNumber" runat="server" CssClass="checkoutTextbox" Width="330px">4444123412341234</asp:TextBox><br />
39 <asp:RequiredFieldValidator ID="valCCNumber" runat="server" ControlToValidate="txtCCNumber"
40 Display="Dynamic" ErrorMessage="Please enter card number."></asp:RequiredFieldValidator><asp:RegularExpressionValidator
41 ID="valCCNumber1" runat="server" ControlToValidate="txtCCNumber"
42 Display="Dynamic" ErrorMessage="Card number invalid." ValidationExpression="^([0-9]{15,16})$"></asp:RegularExpressionValidator> </td>
43 </tr>
44 <tr>
45 <td class="label">Expiration Date (MM/YYYY)<br />
46 <asp:TextBox ID="txtExpDate" runat="server" CssClass="checkoutTextbox" Width="155px">12/2009</asp:TextBox><br />
47 <asp:RequiredFieldValidator ID="valExpDate" runat="server" ControlToValidate="txtExpDate"
48 Display="Dynamic" ErrorMessage="Please enter expiration date."></asp:RequiredFieldValidator><asp:RegularExpressionValidator
49 ID="valExpDate1" runat="server" ControlToValidate="txtExpDate"
50 ErrorMessage="Invalid date format." ValidationExpression="^((0[1-9])|(1[0-2]))\/(\d{4})$" Display="Dynamic"></asp:RegularExpressionValidator>
51 <asp:CustomValidator ID="valExpDate2" runat="server" ClientValidationFunction="ClientValidate"
52 ControlToValidate="txtExpDate" Display="Dynamic" ErrorMessage="Expiration date invalid."
53 OnServerValidate="ServerValidate"></asp:CustomValidator> </td>
54 </tr>
55 <tr>
56 <td class="label">Credit card Type<br />
57 <asp:DropDownList ID="listCCType" runat="server" CssClass="checkoutDropdown">
58 <asp:ListItem>Visa</asp:ListItem>
59 <asp:ListItem>Master Card</asp:ListItem>
60 <asp:ListItem>American Express</asp:ListItem>
61 <asp:ListItem>Discovery</asp:ListItem>
62 </asp:DropDownList></td><td> </td>
63 </tr>
64 </table>
65 <p> </p>
66 <table border="0" cellpadding="0" cellspacing="0" class="checkoutButtonBg" width="100%">
67 <tr>
68 <td align="left"><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="MovePrevious"
69 CssClass="back">Previous</asp:LinkButton></td><td align="right"><asp:LinkButton ID="StepNextButton2" runat="server" CommandName="MoveNext"
70 CssClass="continue">Next</asp:LinkButton></td>
71 </tr>
72 </table>
73 </asp:Panel>
74 </asp:WizardStep>
75 <asp:WizardStep ID="wzdStep4" runat="server" StepType="Finish" Title="Confirmation">
76 <asp:Panel ID="panFicusStep4" runat="server" DefaultButton="FinishButton">
77 <div class="checkOutLabel">
78 Your order will not be processed until you select "Submit Order" below.<br /><br />
79 <strong>Billing address:<br />
80 </strong>
81 <PetShopControl:AddressConfirm ID="billingConfirm" runat="server">
82 </PetShopControl:AddressConfirm><br />
83 <strong>Shipping address:<br />
84 </strong>
85 <PetShopControl:AddressConfirm ID="shippingConfirm" runat="server">
86 </PetShopControl:AddressConfirm>
87 </div>
88 <div class="checkOutLabel">
89 A total of <span class="labelBold">
90 <asp:Literal ID="ltlTotal" runat="server"></asp:Literal></span> will be charged
91 to your credit card, ending with <span class="labelBold">
92 <asp:Literal ID="ltlCreditCard" runat="server"></asp:Literal></span>.
93 </div>
94 <table border="0" cellpadding="0" cellspacing="0" class="checkoutButtonBg" width="100%">
95 <tr>
96 <td align="left"><asp:LinkButton ID="FinishPreviousButton" runat="server" CausesValidation="False"
97 CommandName="MovePrevious" CssClass="back">Previous</asp:LinkButton></td><td align="right"><asp:LinkButton ID="FinishButton" runat="server" CommandName="MoveComplete" CssClass="submit">Submit Order</asp:LinkButton></td>
98 </tr>
99 </table>
100 </asp:Panel>
101 </asp:WizardStep>
102 <asp:WizardStep ID="wzdStep5" runat="server" AllowReturn="False" StepType="Complete"
103 Title="Receipt">
104 <div class="checkOutLabel">
105 Thank you for your order!<br /><br />
106 <PetShopControl:CartList ID="CartListOrdered" runat="server"/>
107 <br />
108
109 <p>
110 A total of <strong>
111 <asp:Literal ID="ltlTotalComplete" runat="server"></asp:Literal></strong> is
112 being charged to your credit card, ending with <strong>
113 <asp:Literal ID="ltlCreditCardComplete" runat="server"></asp:Literal></strong>.</p>
114 <p>
115 If you have any questions regarding this order, please contact our customer service
116 at anytime.</p>
117 <p>
118 The .NET Pet Shop Team</p>
119 </div>
120 </asp:WizardStep>
121 </WizardSteps>
122 <HeaderStyle HorizontalAlign="Left"/>
123 <HeaderTemplate>
124 <%= wzdCheckOut.ActiveStep.Title %>
125 </HeaderTemplate>
126 <StartNavigationTemplate>
127
128 </StartNavigationTemplate>
129 <StepNavigationTemplate>
130
131 </StepNavigationTemplate>
132 <FinishNavigationTemplate>
133
134 </FinishNavigationTemplate>
135 </asp:Wizard>
这个控件定义了要交易的五个步骤,具体我就用图片来表示吧:
步骤一:
步骤二:
步骤三:
步骤四:
步骤五出错了:
服务器 'ZGC-20101011UKH' 上的 MSDTC 不可用。
后来在找到错误原因,并进行了配置。备注:MSDTC是协调跨多个数据库、消息队列个文件的资源管理器服务。
那么第五步不言而喻,是对订单的汇总啦:
原来这个步骤流程倒是挺好用的,姑且记下它。
/******************************************************************************************************/
步骤三用到了一个CustomValidator控件,算了还是把代码贴出来,这样好说明:
<asp:CustomValidator ID="valExpDate2" runat="server" ClientValidationFunction="ClientValidate"
ControlToValidate="txtExpDate" Display="Dynamic" ErrorMessage="Expiration date invalid."
OnServerValidate="ServerValidate">
</asp:CustomValidator>
<asp:TextBox ID="txtExpDate" runat="server" CssClass="checkoutTextbox" Width="155px">12/2009</asp:TextBox><br />
原来在CustomValidator验证控件也可以调用函数,那么来看下这个javascript函数吧:
<script type="text/javascript" language="javascript">
function ClientValidate(source, arguments) {
var dtNow =new Date();//声明一个以当前时间为值的日期对象
var tmp =new String(arguments.Value); //获得TextBox控件的值把
var dtCard =new Date();//声明一个以当前时间为值的日期对象
dtCard.setFullYear(tmp.split("/")[1]);//获得年份
dtCard.setMonth(tmp.split("/")[0]-1);//获得月份
dtCard.setDate(30);//天数设定默认30
if (dtNow < dtCard)//如果写下去的时间大于当前时间 一般会大把 因为她的天数是30了
arguments.IsValid =true;
else
arguments.IsValid =false;
}
</script>