Mercurial > pub > bltoolkit
comparison Demo/Asp.Net/Web/Controls/CreditCardForm.ascx.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 using System; | |
| 2 using System.Web.UI.WebControls; | |
| 3 | |
| 4 using PetShop.ObjectModel; | |
| 5 | |
| 6 namespace PetShop.Web | |
| 7 { | |
| 8 public partial class CreditCardForm : System.Web.UI.UserControl | |
| 9 { | |
| 10 /// <summary> | |
| 11 /// Custom validator to check the expiration date | |
| 12 /// </summary> | |
| 13 protected void ServerValidate(object source, ServerValidateEventArgs value) | |
| 14 { | |
| 15 DateTime dt; | |
| 16 | |
| 17 if (DateTime.TryParse(value.Value, out dt)) | |
| 18 value.IsValid = dt > DateTime.Now; | |
| 19 else | |
| 20 value.IsValid = false; | |
| 21 } | |
| 22 | |
| 23 /// <summary> | |
| 24 /// Property to set/get credit card info | |
| 25 /// </summary> | |
| 26 public CreditCard CreditCard | |
| 27 { | |
| 28 get | |
| 29 { | |
| 30 CreditCard cc = new CreditCard(); | |
| 31 | |
| 32 cc.Type = WebUtility.InputText(listCctype.SelectedValue, 40); | |
| 33 cc.Expiration = WebUtility.InputText(txtExpdate. Text, 7); | |
| 34 cc.Number = WebUtility.InputText(txtCcnumber.Text, 20); | |
| 35 | |
| 36 return cc; | |
| 37 } | |
| 38 | |
| 39 set | |
| 40 { | |
| 41 if (value != null) | |
| 42 { | |
| 43 if (!string.IsNullOrEmpty(value.Number)) txtCcnumber.Text = value.Number; | |
| 44 if (!string.IsNullOrEmpty(value.Expiration)) txtExpdate. Text = value.Expiration; | |
| 45 if (!string.IsNullOrEmpty(value.Type)) listCctype.Items.FindByValue(value.Type).Selected = true; | |
| 46 } | |
| 47 } | |
| 48 } | |
| 49 } | |
| 50 } |
