Code Behind Page Page /Controls/AddressInput.ascx.cs (C#)
Used by Page /Controls/AddressInput.ascx (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Collections;  
5: using System.Web;  
6: using System.Web.Security;  
7: using System.Web.UI;  
8: using System.Web.UI.WebControls;  
9: using System.Web.UI.WebControls.WebParts;  
10: using System.Web.UI.HtmlControls;  
11:   
12: public partial class Controls_AddressInput : System.Web.UI.UserControl  
13: {  
14:     private const string STR_Canada = "Canada";  
15:     private const string STR_UnitedStates = "United States";  
16:     private const string STR_India = "India";  
17:   
18:     public string City  
19:     {  
20:         get { return TextCity.Text; }  
21:         set  
22:         {  
23:             TextCity.Text = value;  
24:         }  
25:     }  
26:   
27:     /// <summary>  
28:     /// Choose a StateOrProvince based on which one is visible  
29:     /// </summary>  
30:     public string State  
31:     {  
32:         get  
33:         {  
34:             if (Country == STR_UnitedStates)  
35:                 return ListUSStates.SelectedValue;  
36:             else if (Country == STR_Canada)  
37:                 return ListCanadaProvinces.SelectedValue;  
38:             else if (Country == STR_India)  
39:                 return ListIndiaStates.SelectedValue;  
40:             else  
41:                 return this.txtState.Text;  
42:         }  
43:         set  
44:         {  
45:             if (Country == STR_UnitedStates)  
46:             {  
47:                 ListUSStates.ClearSelection();  
48:                 ListUSStates.Items.FindByText(value).Selected = true;  
49:             }  
50:             else if (Country == STR_Canada)  
51:             {  
52:                 ListCanadaProvinces.ClearSelection();  
53:                 ListCanadaProvinces.Items.FindByText(value).Selected = true;  
54:             }  
55:             else if (Country == STR_India)  
56:             {  
57:                 ListIndiaStates.ClearSelection();  
58:                 ListIndiaStates.Items.FindByText(value).Selected = true;  
59:             }  
60:             else  
61:                 txtState.Text = value;  
62:         }  
63:     }  
64:   
65:     public string Country  
66:     {  
67:         get { return ListCountries.SelectedItem.Text; }  
68:         set  
69:         {  
70:             ListCountries.ClearSelection();  
71:             ListCountries.Items.FindByText(value).Selected = true;  
72:         }  
73:     }  
74:   
75:     public string CountryCode  
76:     {  
77:         get { return ListCountries.SelectedItem.Value; }  
78:         set  
79:         {  
80:             ListCountries.ClearSelection();  
81:             ListCountries.Items.FindByValue(value).Selected = true;  
82:         }  
83:     }  
84:   
85:     public void RemoveValidationGroups()  
86:     {  
87:         CountryValidator.ValidationGroup = "";  
88:         StateRequiredFieldValidator.ValidationGroup = "";  
89:         ListStateRequiredFieldValidator.ValidationGroup = "";  
90:         ListProvinceRequiredFieldValidator.ValidationGroup = "";  
91:         CityRequired.ValidationGroup = "";  
92:     }  
93:   
94:     public void AddressValidationControlsDisable(bool Disable)  
95:     {  
96:         StateRequiredFieldValidator.Enabled = !Disable;  
97:         ListStateRequiredFieldValidator.Enabled = !Disable;  
98:         ListProvinceRequiredFieldValidator.Enabled = !Disable;  
99:     }  
100:     protected void ListCountries_SelectedIndexChanged(object sender, EventArgs e)  
101:     {  
102:         string LabelState = "State:";  
103:         string LabelProvince = "Province:";      
104:   
105:         if (Country == "United States")  
106:         {  
107:             ListUSStates.Visible=true;  
108:             txtState.Visible=false;  
109:   
110:             LabelStateOrProvince.Text = LabelState;  
111:   
112:             StateRequiredFieldValidator.Enabled = false;  
113:             ListProvinceRequiredFieldValidator.Enabled = false;  
114:             ListIndiaStatesValidator.Enabled = false;  
115:             ListStateRequiredFieldValidator.Enabled = true;  
116:         }  
117:         else if (Country == "Canada")  
118:         {  
119:             txtState.Visible=false;  
120:             ListCanadaProvinces.Visible=true;  
121:               
122:             ListUSStates.Visible=false;  
123:   
124:             ListStateRequiredFieldValidator.Enabled = false;  
125:             StateRequiredFieldValidator.Enabled = false;  
126:             ListIndiaStatesValidator.Enabled = false;  
127:             ListProvinceRequiredFieldValidator.Enabled = true;              
128:               
129:         }  
130:         else if (Country == "India")  
131:         {  
132:             txtState.Visible = false;  
133:             ListIndiaStates.Visible = true;  
134:   
135:             ListUSStates.Visible = false;  
136:   
137:             ListStateRequiredFieldValidator.Enabled = false;  
138:             StateRequiredFieldValidator.Enabled = false;  
139:             ListProvinceRequiredFieldValidator.Enabled = false;  
140:             ListIndiaStatesValidator.Enabled = true;  
141:   
142:         }  
143:         else  
144:         {  
145:             ListUSStates.Visible=false;  
146:             ListCanadaProvinces.Visible=false;  
147:               
148:             txtState.Visible=true;  
149:             LabelStateOrProvince.Text = LabelProvince;  
150:               
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.