Andrew Lee
Andrew Lee

Reputation:

Localization in .NET

Hi I am using Resoursce files as described here: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx

I am setting the culture info programatically as opposed to at the top in the page declaration. Do I need to declare the culture info for each page? Is there something I can do to change the culture info for all pages using one line? I am using a master page. Thank you.

Upvotes: 0

Views: 225

Answers (3)

Greg
Greg

Reputation: 16680

If you just want the culture to be set to the browser's settings, follow this answer. If you need to set the culture to something programmatically, use the following:

public class MyPage : Page
{
    protected override void InitializeCulture()
    {
        base.InitializeCulture();
        Thread.CurrentThread.CurrentCulture = ...;
        Thread.CurrentThread.CurrentUICulture = ...;
    }
}

Then make sure all of your pages inherit from MyPage instead of Page.

Upvotes: 0

pmarflee
pmarflee

Reputation: 3428

You can set the default culture in web.config by adding through the globalization element.

Upvotes: 1

Jason Coyne
Jason Coyne

Reputation: 6636

Set the culture in the code behind for the master page, or on a base class that all of your pages descend from.

Upvotes: 1

Related Questions