开发者

globalization not working in asp.net

I am trying to implement Globalization in my application but for some reason its not working

Please find the code below

Default.aspx

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Button ID="button1" meta:resourceKey="button1" runat="server" Text="" />
</asp:Content>

Default.aspx.cs

 protected override void InitializeCulture()
    {
        Thread.CurrentThread.CurrentCulture =
开发者_C百科           CultureInfo.CreateSpecificCulture("en");
        Thread.CurrentThread.CurrentUICulture = new
            CultureInfo("en-US");

            base.InitializeCulture();
    }

name of my resource file is Default.aspx.en-us.resx in "App_LocalResources" folder it carries only one key key-->button1.Text value--> Save

Please advice


I followed your instructions and got the same results as you, except for the error. The problem I found was that unless there is a default resource file then the language specific one does not work for some reason.

So I made a copy of the default.aspx.en-us.resx, and named it default.aspx.resx in the same directory, and then made sure that the default.aspx.en-us.resx had a different value than the default and it worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜