1
votes

I have ASP.NET WebForms application c# based.

I have input text

<input type="text" id="txtUsername" name="username" runat="server"
       placeholder="<%$ Resources:Resource, Username %>" />

and a label

<label for="Username"><%= Resources.Resource.Username%></label>

also i create 2 resources files Resource.resx and Resource.en-GB.resx under App_GlobalResources

Resource.resx:

Username: username

Resource.en-GB.resx:

Username: email

When user switch between languages i used the following code

System.Threading.Thread.CurrentThread.CurrentUICulture = new 
System.Globalization.CultureInfo(code);
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(code);
Resources.Resource.Culture = new System.Globalization.CultureInfo(code);

and the code will equal en or en-GB depending on the user selection.

Problem:

When we run the project and the code = en-GB, the label resources appears as Resource.en-GB.resx (email) while place holder as Resource.resx (username).

That's mean <%= Resources.Resource.Username%> works perfect, while changing the culture doesn't change the <%$ Resources:Resource, Username %>.

Any Suggestions?

1

1 Answers

0
votes

Assuming that "code" variable in your code is the culture code:

Thread.CurrentThread.CurrentUICulture = new CultureInfo(code);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(code);

hope this helps!