Localize With The Page Control

ou can use the Page control to specify a certain culture for individual pages in your ASP.NET application.

The Page control can be used for setting properties for a Web page. Culture is one of the properties that you can set for a page.

When using the Page control to localize, each culture that you support must have a separate Web page for that culture. This enables different team members to work on various parts of your Web application without affecting each other.

You can create a separate page for each culture. You must have a method of determining which culture to use. You can allow the user to select a culture from a drop-down list. Based on this selection, you can use a case statement to redirect the user to the appropriate page. On these pages, you can use the @Page directive's Culture attribute to set the culture. When displaying the date on the page, you can use the Culturelnfo.CurrentCulture to ensure the date is formatted properly.

You can have the user select a culture from a dropdown list of cultures and redirect them to an appropriate page based on the culture. Each page will be set up for different cultures and display the localized date.

LOCALIZE WITH THE PAGE CONTROL

LOCALIZE WITH THE PAGE CONTROL

File Edit Format Help

<%@Paqe Lanouaqe="C#" ResponseEncodinq-'utf-i

^Import Namespace-'System.Threading"0/ <%(q?lmport Namespace-'System. Globalization"' cHTMLs <HEAD>

cFONTFACE ="Verdana"=-

=;H3>Welcome to mylifetimegoals.com</H3> Select your culture below:

CP/5

l<SPAN ID-'spanMessaoe" RÜNAT-'Server" /=• </FORM>

-0 Add a submit button control.

_Q Add a span control on the form to display messages.

GenericTemplate.aspx from the Code Templates directory.

Add a heading to the page.

< Add a message to the user.

_Q Add a form control.

LB Create a drop-down list that has several languages from which to choose.

File Edit Format Help

<%@Paqe Lanouaqe="C#" ResponseEncodinq-'utf-i

^Import Namespace-'System.Threading"0/ <%(q?lmport Namespace-'System. Globalization"' cHTMLs <HEAD>

cFONTFACE ="Verdana"=-

=;H3>Welcome to mylifetimegoals.com</H3> Select your culture below:

<ASP:DROPDOWNLISTID="dropdownllstCultures" RUNAT="Server"> <ASP:LISTITEM VALUE="en-US"sEnglish</ASP:LISTn~EM=-<ASP:LISTITEM VALUE="es-ES">Spanish</ASP:LISTITEM> <A3P:LISTITEM VALUE="ja-JP">Japanesec/ASP:LISTITEM>

</ASP:DROPDOWNLIST?_

|<ASP:BUTTQN TEXT="Submit" OnClick="SubmitBtn Click" RIJNAT="Setver7H

CP/5

l<SPAN ID-'spanMessaoe" RÜNAT-'Server" /=• </FORM>

GenericTemplate.aspx from the Code Templates directory.

Add a heading to the page.

< Add a message to the user.

_Q Add a form control.

LB Create a drop-down list that has several languages from which to choose.

-0 Add a submit button control.

_Q Add a span control on the form to display messages.

° Add the @Page directive to the page and set the ResponseEncoding attribute to UTF-8, as well as the Language attribute to C#.

-Q Add an alias to the System.Threading and System.Globalization namespaces.

Was this article helpful?

0 0

Post a comment