Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localize application on button click

I have in my project mainMaster page were locates imageButtons:

<asp:ImageButton ID="RU" ImageUrl="/Images/RU.png" runat="server" onclick="RU_Click">                
<asp:ImageButton ID="USA" ImageUrl="/Images/USA.png" runat="server" onclick="USA_Click" />  

here's OnClick functions:

protected void RU_Click(object sender, ImageClickEventArgs e)
{
    Session["MyCulture"] = CultureInfo.CreateSpecificCulture("ru-RU");
    Server.Transfer(Request.Url.LocalPath);     
}

protected void USA_Click(object sender, ImageClickEventArgs e)
{
    Session["MyCulture"] = CultureInfo.CreateSpecificCulture("en-AU");
    Server.Transfer(Request.Url.LocalPath);  
}

also I have two .resx files but how cane I link press buttons with

<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Main, Name%>" />
like image 978
Darien Fawkes Avatar asked Dec 02 '25 19:12

Darien Fawkes


1 Answers

Your question is not clear, but let me clear one thing up for you that might be your problem.

You can set Culture only in the InitializeCulture event:

protected override void InitializeCulture()
{
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-AU");
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-AU");
    base.InitializeCulture();
}
like image 176
Muhammad Akhtar Avatar answered Dec 05 '25 10:12

Muhammad Akhtar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!