Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,:confused:

i create a simple webpage to test the Localization. i create two pages.
Default.aspx & Welcome.aspx .
i use two languages ENglish & FRench. i already created Localized folder & .RESX of both.
but i can change only current page languages. using UIculture.
but i click on the link for Welcome.aspx.... it still show me ENglish, not showing french. Language conversation only going on Default.aspx page.

here is my Coding:-
for DEFAULT.ASPX:

XML
<form id="form1" runat="server">
    <div>
        <asp:Label ID="wlcm_msg" runat="server" meta:resourcekey="wlcm_msgResource1"></asp:Label>
        <br />
        <br />
        <asp:Label ID="country_name" runat="server"
            meta:resourcekey="country_nameResource1"></asp:Label>
        <br />
        <br />
        <asp:LinkButton ID="page_2" runat="server" meta:resourcekey="page_2Resource1"
            onclick="page_2_Click" PostBackUrl="~/Welcome.aspx"></asp:LinkButton>
        <br />
        <br />
        <asp:Label ID="langBT" runat="server"></asp:Label>
        <br />
        <asp:LinkButton ID="fr_lang" runat="server"
            PostBackUrl="~/Default.aspx?Language=fr-FR">France</asp:LinkButton>
&nbsp;
        <asp:LinkButton ID="en_lang" runat="server"
            PostBackUrl="~/Default.aspx?Language=en-US">English</asp:LinkButton>
    </div>
    </form>


and for DEFAULT.ASPX.CS in C# coding:

C#
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected override void InitializeCulture()
    {
        if (Request["Language"] != null)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(Request["Language"].ToString());
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request["Language"].ToString());
        }
        base.InitializeCulture();
    }
}


HERE is the coding of WELCOME.ASPX page:

XML
<form id="form1" runat="server">
    <div>
        <asp:Label ID="welcome_page" runat="server"
            meta:resourcekey="welcome_pageResource1"></asp:Label>
        <br />
        <asp:Image ID="country_flag" runat="server" Height="154px" Width="179px"
            meta:resourcekey="country_flagResource1" />
        <br />
        <br />
        <asp:LinkButton ID="back_bt" runat="server" meta:resourcekey="back_btResource1"
            PostBackUrl="~/Default.aspx"></asp:LinkButton>
    </div>
    </form>


Now what i have to write in welcome's CS file???

thank you!
-Ashish
Posted

This is because you are setting the culture information only on default.aspx page.

If you want to work it on welcome.aspx then you need to set the same on this page too.

Do it in master page or use an HTTP Handler to maintain culture related information through out the application.

see Changing web application Culture on the fly[^] for more help.
 
Share this answer
 
v2
Comments
Yusuf 14-Feb-11 11:33am    
fixed link for url
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900