364,088 Members | 5420 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Master Page doesn't work with the Local Resource !!

JustRun
100+
P: 127
Hi,

I'm developing a web site using asp.net with C#, this site contains a MasterPage, UserControles, Pages.

What i need to do is to make my site supports MultiLanguage, so I put a dropDownList in my MasterPage, But the language doesn't change when I switch between them, Here is my code (Only pages that inherit from MasterPage):

/******************** MasterPage.master ********************/

Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:DropDownList ID="cmbCulture" runat="server" AutoPostBack="True" Font-Bold="True"
  3.                                 ForeColor="#3F3F3F" Width="200px">
  4.           <asp:ListItem>Auto</asp:ListItem>
  5.            <asp:ListItem Value="ar-EG">Arabic</asp:ListItem>
  6.            <asp:ListItem Value="en-US">English</asp:ListItem>
  7.  </asp:DropDownList>
  8.  
and I use a BaseClass, That I inherit from instead of inherit from a page like that:

/******************** BaseClass.cs ********************/
Expand|Select|Wrap|Line Numbers
  1.     protected override void InitializeCulture()
  2.     {
  3.         string culture = Request.Form["cmbCulture"];
  4.         if (string.IsNullOrEmpty(culture))
  5.             culture = "Auto";
  6.         //Use this
  7.         UICulture = culture;
  8.         Culture = culture;
  9.         //OR This
  10.         if (culture != "Auto")
  11.         {
  12.             System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
  13.             System.Threading.Thread.CurrentThread.CurrentCulture = ci;
  14.             System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
  15.         }
  16.  
  17.         base.InitializeCulture();
  18.     }
  19.  
/******************** Page.aspx ********************/
Expand|Select|Wrap|Line Numbers
  1. public partial class administrator_NewUser : BaseClass
  2. {
  3.     protected void Page_Load(object sender, EventArgs e)
  4.     {
  5.  
  6.     }
  7. }
  8.  

NOTE:

The Default Page doesn't inherit from the Master page, but inherit the BaseClass, and it works fine.

The problem with pages that inherit from MasterPage !!

ANY IDEAS !!
Oct 19 '08 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 7,034
I have a feeling it's:

string culture = Request.Form["cmbCulture"];

Consider storing the preferred culture in ViewState or Session instead.

In the method that handles the selected index changed event for the language drop down list, set the preferred culture and save it in ViewState or Session then cause a post back to the server so that your page is refreshed (by this I mean use the Response.Redirect() and call the current page so that the page is reloaded with the preferred culture).

(PS I hope that you realize that Arabic is backwards compared to English....good luck with that!)

-Frinny
Oct 22 '08 #2

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework