Using two controls to determine how information is to be displayed, with localisation of the options available.
In a recent module application I had one control within which the display options were configured, a second control was then used to present the information based on the selected style. In the selection control a dropdownlist was used to present the different display styles.
When we are only handling a single fixed language localisation this is a simple matter of looking for the different strings and responding accordingly.
In the Selection control I had a dropdownlist ddlDisplayStyle which was populated using:
ddlDisplayStyle.Items.Add("Listing")
ddlDisplayStyle.Items.Add("Review")
ddlDisplayStyle.Items.Add("Grid")
ddlDisplayStyle.Items.Add("Directory")
ddlDisplayStyle.SelectedValue = Settings("StyleID")
In the presentation control a select was used to handle the different display styles:
StyleID = Settings("StyleID")
Select Case StyleID
Case "Listing"
viewAs_Listing()
Case "Review"
viewAs_Review()
Case "Grid"
viewAs_Grid()
Case "Directory"
viewAs_Directory()
Case Else
End Select
Our requirement is to provide localisation for the different styles. To do this we need to source the words used from the localisation file associated with the control. However, simply replacing the existing content with the localisation value will produce a failure on the select in the presentation control. We therefore need to add both a text and value parameter to each of our dropdownlist rows. This is illustrated in the listing below.
ddlDisplayStyle.Items.Add(New ListItem(Services.Localization.Localization.GetString("Listing", LocalResourceFile), "Listing"))
ddlDisplayStyle.Items.Add(New ListItem(Services.Localization.Localization.GetString("Review", LocalResourceFile), "Review"))
ddlDisplayStyle.Items.Add(New ListItem(Services.Localization.Localization.GetString("Grid", LocalResourceFile), "Grid"))
ddlDisplayStyle.Items.Add(New ListItem(Services.Localization.Localization.GetString("Directory", LocalResourceFile), "Directory"))
Using the listing above the user sees their localised text in the dropdownlist, but the two controls use our values of Listing, Grid, Review and Directory fo determining the presentation style.
NAT November 2005