Working with the Address Detail Web Part
The Address Detail Web Part lets shoppers create new or edit their existing recorded addresses. Both shipping and billing addresses are grouped in the list and the shopper can display only shipping, only billing, or both types of address.
The shopper can also mark an address for shipping or billing purposes. Once marked as such, the shopper can further designate an address as the primary or secondary address for billing or shipping (or both). A single address can be both a shipping and billing address and can be the primary address in both categories. The system allows only one primary shipping and one primary billing address.
From the Address Detail Web Part, shoppers can remove an address. When shoppers remove an address, they are prompted to confirm their action. Shoppers can also choose to edit or add a new address, which redirects them to the Address Detail Web Part.
The field labels are dynamic based on the locale and culture of the page. The Address Detail Web Part lets shoppers view their recorded addresses and provides some administrative tasks on those addresses. Both shipping and billing addresses are grouped in the list and shoppers are able to display only shipping, only billing, or both types of address.
Architecture
The Address Detail Web Part contains the following components:
AddressListWebPart/SPAddressListWebPart. Dynamically loads the AddressList user control.
AddressType.ascx. A Web user control that you use to manage address types through a collection of check boxes to represent address types. This user control has a property named EnableAddressTypeUpdate that, when set to True, will update the address type in the back-end repository, and otherwise will manage the check boxes' checked status. In the Address List Web Part, this property is set to True.
ReadOnlyAddressDetail.ascx. This user control uses MVP design pattern, used to display address properties in read-only mode.
AddressList.ascx. A Web user control that displays a list of the shoppers' addresses. The shopper is able to filter the list by categories presented in two checkboxes. The shopper is also able to use links and actions presented in the list to redirect the Address Detail Web part to edit or create a new address. Two checkboxes are displayed beneath each address that lets the shopper mark an address as a shipping address or a billing address.
Properties
The following table lists and describes the properties for the Address Detail Web Part:
Property |
Maps to |
Type |
Description |
Default |
---|---|---|---|---|
Use "deletion confirmation" pop-up |
ConfirmDeletion |
|||
Display "back" button |
AllowBackUrlButton |
|||
Address Detail" page URL |
AddressDetailUrl |
|||
"Action" URL parameter |
ActionQueryParameter |
String |
This property sets the name of the URL query string parameter which is used to specify the action that this web part should perform. Default value is "act". This value should not be changed. If it is changed, all links to this page, in code or mark-up, will need to be modified accordingly. |
Blank |
"Address detail" section title text |
String |
Sets the text displayed above the address detail area. |
Blank |
|
"Address list" section title text |
AddressListHeaderLiteral |
|||
"Address Id" URL parameter |
AddressIdQueryParameter |
String |
This property sets the name of the URL query string parameter which is used to specify the id of the address to load. Default value is "address". This value should not be changed. If it is changed, all links to this page, in code or mark-up, will need to be modified accordingly. |
Blank |
"Is billing address" check box text |
BillingAddressCheckBoxText |
String |
Sets the text displayed beside the "is billing address" check box. |
Blank |
"Add new address" button text |
ButtonAddNewAddressText |
|||
"Back" button text |
ButtonBackText |
|||
"Edit" button text |
ButtonEditText |
|||
"Cancel" button text |
String |
Sets the text displayed on the "cancel" button. |
Blank |
|
"Remove" button text |
ButtonRemoveText |
String |
Sets the text displayed on the "remove" button. |
Blank |
"Save" button text |
String |
Sets the text displayed on the "save" button. |
Blank |
|
"City" label text |
CityLabelText |
String |
Sets the text displayed beside the "city" text box. |
Blank |
"City is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "city". |
Blank |
|
Use "delete confirmation" pop-up |
Boolean |
If checked, causes a pop-up to be displayed asking the user to confirm the deletion. You can configure the text displayed using the "Delete confirmation pop-up text" field. |
True |
|
"Country" label text |
CountryLabelText |
String |
Sets the text displayed beside the "country" text box. |
Blank |
"Country is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "country". |
Blank |
|
CSS class |
CssClass |
String |
Sets the style sheet "class" name used when outputting the HTML markup of this web part. |
Blank |
"Default billing address" check box text |
DefaultBillingAddressCheckBoxText |
String |
Sets the text displayed beside the "set as default billing address" check box. |
Blank |
"Default shipping address" check box text |
DefaultShippingAddressCheckBoxText |
String |
Sets the text displayed beside the "set as default shipping address" check box. |
Blank |
"Delete confirmation" pop-up text |
DeleteConfirmationMessage |
String |
Sets the text displayed on the delete confirmation pop-up. |
Blank |
"First name" label text |
String |
"First name" label text |
Blank |
|
"First name is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "first name". |
Blank |
|
Instructional text |
InstructionTextLiteral |
String |
Sets the text block displayed above the address detail area. Can be used to provide instructions to end users. |
Blank |
"Last name" label text |
String |
Sets the text displayed beside the "last name" text box. |
Blank |
|
"Last name is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "last name". |
Blank |
|
"Line 1" label text |
Line1LabelText |
String |
Sets the text displayed beside the "line 1" text box. |
Blank |
"Line 1 is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "line 1". |
Blank |
|
"Line 2" label text |
Line2LabelText |
String |
Sets the text displayed beside beside the "line 2" text box. |
Blank |
"Billing addresses list" text |
ListBillingAddressesText |
|||
"Shipping addresses" list text |
ListShippingAddressesText |
|||
"Phone number format is invalid" message |
String |
Sets the text displayed when the user submits an invalid value for "phone number". |
Blank |
|
"Phone number" label text |
PhoneNumberLabelText |
String |
Sets the text displayed beside the "phone number" text box. |
Blank |
"Phone Number is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "phone number". |
Blank |
|
On completion, go to URL |
String |
Sets the page URL to redirect to once the operation has completed. |
Blank |
|
"Postal code" label text |
PostalLabelText |
String |
Sets the text displayed beside the "postal code" text box. |
Blank |
"Postal code is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "postal code". |
Blank |
|
"Province" label text |
ProvinceLabelText |
String |
Sets the text displayed beside the "province" text box. |
Blank |
"Postal code is invalid" message |
String |
Sets the text displayed when the user submits an invalid value for "postal code". |
Blank |
|
Layout : # of columns |
RepeatColumns |
|||
Layout : Orientation |
RepeatDirection |
|||
"Zip code is invalid" message |
String |
Sets the text displayed when the user submits an invalid value for "zip code". |
Blank |
|
"Is shipping address" check box text |
ShippingAddressCheckBoxText |
String |
Sets the text displayed beside the "is shipping address" check box. |
Blank |
"State" label text |
StateLabelText |
String |
Sets the text displayed beside the "state" drop-down. |
Blank |
"State is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "state". |
Blank |
|
"View" label text |
ViewAddressesLabelText |
|||
Default Mode |
String |
Sets the mode that the web-part will be in when the page first displays. Valid values are "Create", "Edit", "Delete" or "View". |
Blank |
|
"Zip code" label text |
ZipLabelText |
String |
Sets the text displayed beside the "zip code" text box. |
Blank |
"Zip code is required" message |
String |
Sets the text displayed when the user submits the form without supplying a value for "zip code". |
Blank |
Customization
You can customize the Address Detail Web Part by modifying the ASCX file.
Important Note: |
---|
If you make modifications to the ASCX file to customize a Web Part, rename the modified ASCX file to avoid the risk of overwriting your Web Part customizations during an upgrade. |
Error Handling
There is no design-time error handing required for this Web Part.
API Dependencies
The Address Detail Web Part is dependent on the UserProfile API. Addresses are related to a user profile and, therefore, are retrieved by using QueryRelatedItem<Address>.
Remarks
You can easily modify the validation expression for a telephone number format. In the following example from the user control AddressDetail.ascx, the telephone number format is set to "[-() 0123456789]{6,20}". When changed, you do not need to restart the Web application; the new validation expression will be active immediately after saving the user control.
<div class="Skin_Column80">
<asp:TextBox ID="TxtPhoneNumber" MaxLength="20" TabIndex="1" />
<asp:RequiredFieldValidator ID="PhoneNumberRequired" EnableClientScript="false" ControlToValidate="TxtPhoneNumber" ValidationGroup="AddressDetail" Text="*" Display="Dynamic" />
<asp:RegularExpressionValidator ID="PhoneNumberFormatValidator" EnableClientScript="false" ControlToValidate="TxtPhoneNumber" ValidationExpression="[-() 0123456789]{6,20}" ValidationGroup="AddressDetail" Text="*" Display="Dynamic" />
</div>
See Also
Other Resources
Developing with SharePoint Commerce Services