Globalization issue on asp.net: this is not an update of accented words

I created a website in three languages: English, Portuguese and Spanish.

Everything works fine, except for one thing: it did not update BoundField when an underlined word was loaded into it.

Below is a field that is not updated in gridview in MEMGridView.ascx:

<asp:BoundField DataField="Ocupacao" HeaderText="Ocupação" SortExpression="Ocupação" meta:resourcekey="BoundFieldResource9"> <ItemStyle HorizontalAlign="Center" /> </asp:BoundField> 

There are three files in App_LocalResources with the following values:

  • MEMGridView.ascx.resx (English by default) - BoundFieldResource9.HeaderText - "Fill Rate"
  • MEMGridView.ascx.pt-BR.resx - BoundFieldResource9.HeaderText - "Ocupação"
  • MEMGridView.ascx.es.resx - BoundFieldResource9.HeaderText - "Occupation"

When the page loads for the first time, it shows "Fill Rate" . Then I change the language to Spanish and it shows "Ocupación" . If I return to load the page in English, it will update all the fields except those highlighted. Therefore, he continues to show "Ocupación" instead of "Fill Rate" .

I have no clue about what might happen.

- Update - Additional Information -

MEMGridView is a UserControl inside DashBoard.aspx. Each time someone changes the language value in ddlLanguage (drop-down list) or clicks the Refresh button, a postback is created.

This is a MEMGridView event designed to update fields (in fact, it updates all fields except selected ones).

 public partial class MEMGridView : UserControl { ... protected override void FrameworkInitialize() { if (!string.IsNullOrEmpty(Request["ddlLanguage"])) { string str = Request["ddlLanguage"]; //Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(str); Thread.CurrentThread.CurrentUICulture = new CultureInfo(str); } else { string preferredLanguage; if (Request.QueryString["Language"] != null) preferredLanguage = Request.QueryString["Language"]; else preferredLanguage = Request.UserLanguages[0]; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(preferredLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(preferredLanguage); } base.FrameworkInitialize(); } 
+6
source share
3 answers

The same problem was detected. Fixed by replacing BoundField with TemplateField, also:

 <asp:TemplateField ...> <ItemTemplate><%# Eval( "Ocupacao" ) %></ItemTemplate> </asp:TemplateField> 
+1
source

Could you override InitializeCulture from a page (not MasterPage)?

http://msdn.microsoft.com/en-us/library/system.web.ui.page.initializeculture(v = vs .110) .aspx

Also, when you say that you “come back to load the page in English,” how did you do it? Is it through browser navigation or Server.Transfer? If this is the last, you used:

Server.Transfer(Request.Url.PathAndQuery, false);

0
source

http://www.c-sharpcorner.com/UploadFile/4d9083/what-is-globalization-and-localization-in-Asp-Net/

this link will help you


Text = "<% $ Resources: Resource, AccCode%>"

"<% $ Resources: the name of the main resource, the" Add resource name "field that you want to display%>"

<asp: Label ID = "lblresdisplay" Font-Size = "Large" runat = "server" Text = "<% $ Resources: Resource, AccCode%>">

<asp: Label ID = "Label1" Font-Size = "Large" runat = "server" Text = "<% $ Resources: Resource, AccCode%>">


- protected override void InitializeCulture ()

 { base.InitializeCulture(); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Session["Culture"].ToString()); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Session["Culture"].ToString()); } 

}

0
source

All Articles