473,440 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

MasterPage.InitializeCulture()': no suitable method found to override

JustRun
127 100+
Hi,

I'm trying to develop a MultiLanguage web site using ASP.NET 2.0 with C#
My problem is: I want to make my MasterPage support switching among languages, but when i put the "InitializeCulture()" inside the masterpage.cs, I got this erreor:

MasterPage.InitializeCulture()': no suitable method found to override

Note the following code works fine with xxx.aspx page, but not with MasterPage
Here is my code:
Expand|Select|Wrap|Line Numbers
  1.     public override void InitializeCulture()
  2.     {
  3.         string culture = Request.QueryString["lang"];
  4.         //string culture = Request.Form["cmbCulture"];
  5.  
  6.         if (string.IsNullOrEmpty(culture))
  7.             culture = "Auto";
  8.         //Use this
  9.         UICulture = culture;
  10.         Culture = culture;
  11.         //OR This
  12.         if (culture != "Auto")
  13.         {
  14.             System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
  15.             System.Threading.Thread.CurrentThread.CurrentCulture = ci;
  16.             System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
  17.         }
  18.  
  19.         base.InitializeCulture();
  20.     }
Oct 14 '08 #1
4 14154
Frinavale
9,735 Expert Mod 8TB
The MasterPage class is used as a template for your web application.

When an HTTP request is made for a page at run time, the master page and content pages are combined into a single class with the same name as the content pages. The resulting compiled, merged class derives from the Page class.

This means that you cannot override the InitializeCulture method in the MasterPage page class. You override this method in your aspx page.

-Frinny
Oct 14 '08 #2
JustRun
127 100+
Yes Frinny,

Thank you, I got it, I created a BaseClass.cs. this class inherit System.Web.UI.Page and all my xxx.aspx inherit this class.

Thank you,
Oct 15 '08 #3
@JustRun
I'm trying to do the same thing and getting the same error, here's my code below. I'm new to C# can either of you explain further how to override my method in my aspx page?
Expand|Select|Wrap|Line Numbers
  1. using System.Globalization;
  2. using System.Threading;
  3. using System.Resources;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10.  
  11.  
  12. public partial class MasterPage : System.Web.UI.MasterPage
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.  
  17.     }
  18.  
  19.     protected void languageListIndexChange(object sender, EventArgs e)
  20.     {
  21.     }
  22.  
  23.     protected override void InitializeCulture()
  24.     {
  25.         if (Request.Form["languageList"] != null)
  26.         {
  27.  
  28.             String selectedLanguage = Request.Form["languageList"];
  29.             UICulture = selectedLanguage;
  30.             Culture = selectedLanguage;
  31.             Thread.CurrentThread.CurrentCulture =
  32.             CultureInfo.CreateSpecificCulture(selectedLanguage);
  33.             Thread.CurrentThread.CurrentUICulture = new
  34.             CultureInfo(selectedLanguage);
  35.  
  36.         }
  37.  
  38.         base.InitializeCulture();
  39.     }
  40. }
Oct 5 '11 #4
Frinavale
9,735 Expert Mod 8TB
Garychappel,

To fix this problem remove the protected override void InitializeCulture() method from the MasterPage.

Put it into your ASPX pages instead.

See my explanation for why in post #2 in this thread.

-Frinny
Oct 5 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hai Nguyen | last post by:
Would anybody please tell me what is this error and what i should do I have 5 files: page1.aspx,page1.aspx.cs; page2.aspx.page2.aspx.cs and page3.cs both page1.aspx.cs and page2.aspx.cs inherit...
1
by: Daves | last post by:
I am using 2.0 masterpages. All content pages use some common variables, for example the DB connection string. Also some pages return links which are located in a "sublink" area in the masterpage....
0
by: Mark Parter | last post by:
I've "converted" the code at http://www.eggheadcafe.com/articles/20040613.asp to VB.NET as I'd like to implement this as my application uses quite complex GridViews and various other controls on...
9
by: User | last post by:
OK, I asked in a reply, but I've wasted far too long so I'm going to put a new post out there in hopes that it will be more visible. I have a MasterPage. I want to call a method declared in that...
0
by: Maury | last post by:
Hello, I ovverride the method InitializeCulture of a page to change programmatically a language in a site, I would like to do this after the user clicks on a button, but the button_click event...
1
by: ad | last post by:
Hi, I have set the this.Page.Theme in a MasterPage, but it no affect. I have set break point at this line, but it never execute. void Page_PreInit(object sender, System.EventArgs args) {...
7
by: WT | last post by:
Hello, It seems that when a control is set into a ContentPlaceHolder in a page using a MasterPage, it's id is change and FindControl(ID) no more works, is it normal, how to override this or...
0
by: maz77 | last post by:
I've made my Masterpage with a Header, a LeftBar and a Content but only the Content is a COntentPlaceHolder; I've changed the language of all controls in Content overriding "InizializeCulture()"...
5
by: =?Utf-8?B?SGVyYg==?= | last post by:
My long-running ASP application just stopped working today. I rebuilt and republished, but to no avail. The full error is: Server Error in '/NuclearDedication' Application....
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.