Global Resources in Text

I have a problem when I want to change the language of my website. For this I use Global Resources. When I use the default language, it shows the correct text. Then there is no problem.

But when I change Culture, it does not update the text in the ASP.NET management properties. I have no idea why.

This code works great

<h1><%= Resources.Default.Register %></h1>

But this code unfortunately does not change its language

<asp:Button ID="Button2" runat="server" Text="<%$ Resources:Default, Register %>" />

I change the language by clicking on LinkButton, for example

protected void lbNL_Click(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-BE");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-BE");

            Page.Culture = "nl-BE";
            Page.UICulture = "nl-BE";

        }

Could you help me?

Vincent

+3
source share
1 answer

This is how I change my language from English (default) to French.

<h3><asp:Label runat="server" ID="lblWelcome" Text="<%$ Resources:Resource, Welcome %>" /></h3>

I have to use a control like asp: Label or asp: Literal.

App_GlobalResources Resource.fr.resx. - .

, , fr

** * ** ** * EDIT * * * * * * * * *

. , InitializeCulture.

protected override void InitializeCulture()
{
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-BE");
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-BE");

    base.InitializeCulture();
}
+2

All Articles