8.11. Localizing Client-Side Data in a Web Forms Application
Problem
You need to format dates and currency values according to the culture of the client rather than the server.
Solution
Use client culture and encoding to return data to the client formatted according to the client's localization settings rather than the server's settings.
Follow these steps:
Create a C# ASP.NET web application named
LocalizeWebFormsApplication.Add the following controls to the Default.aspx design surface:
RadioButtonListnamedcultureRadioButton. Add four members:en-US, en-CA, ja-JP, andfr-FR.LabelnamedcultureNameLabel. Add the textCultureName: in front of the label control as the description.LabelnamedcultureEnglishNameLabel. Add the textCultureEnglishName: in front of the label control as the description.LabelnamedcultureNativeNameLabel. Add the textCultureNativeName: in front of the label as the description.LabelnameddateLabel:. Add the textDate: in front of the label as the description.LabelnamedshortDateLabel:. Add the textShortDate: in front of the label as the description.LabelnamednumberLabel:. Add the textNumber: in front of the label as the description.LabelnamedcurrencyLabel:. Add the textCurrency: in front of the label as the description.
The completed layout of the Web Form page Default.aspx is shown in Figure 8-21.

Figure 8-21. Layout for Default.aspx in LocalizeWebFormApplication ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access