473,785 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

JustRun
127 New Member
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 "InitializeCult ure()" inside the masterpage.cs, I got this erreor:

MasterPage.Init ializeCulture() ': 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 14182
Frinavale
9,735 Recognized Expert Moderator Expert
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 InitializeCultu re method in the MasterPage page class. You override this method in your aspx page.

-Frinny
Oct 14 '08 #2
JustRun
127 New Member
Yes Frinny,

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

Thank you,
Oct 15 '08 #3
garychappel
1 New Member
@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 Recognized Expert Moderator Expert
Garychappel,

To fix this problem remove the protected override void InitializeCultu re() 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
1403
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 page3 page3.cs is like a library to share common methods I got this error
1
2788
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. So the masterpage code would 1) create the public string DBConn and 2) check the public string SubLinks if it contains any links after the content page was run (if not, hide the sublink bar). Using Page_OnLoad event the masterpage code is run...
0
1191
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 some pages (viewstate alone was 110Kb+ on some pages!!). Anyway, I've setup the classes required and created a test page which inherits from the new BasePage class. It works well. How can I now use this in an environment that uses mostly Master...
9
1915
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 class from a Page that uses the MasterPage. How do I do that? public partial class List : System.Web.UI.MasterPage { protected ArrayList m_SortList;
0
1411
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 raises after the InitializeCulture event so I have to click twice to view the new language... how can I fix this? Thanks! M.
1
6889
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) { this.Page.Theme = "Web"; }
7
1984
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 retrieve the controls OnInit handler with a FindControl ? Thanks again for help. CS
0
1194
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()" method. Now I'd like to make the same with Header and Leftbar, but I really don't know how... cause MasterPage extends Control (not Page) and it hasn't any InizializeCulture() to override... Thanks. MAX
5
7352
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. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.