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: - public override void InitializeCulture()
-
{
-
string culture = Request.QueryString["lang"];
-
//string culture = Request.Form["cmbCulture"];
-
-
if (string.IsNullOrEmpty(culture))
-
culture = "Auto";
-
//Use this
-
UICulture = culture;
-
Culture = culture;
-
//OR This
-
if (culture != "Auto")
-
{
-
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
-
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
-
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
-
}
-
-
base.InitializeCulture();
-
}
4 14184 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
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,
@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? -
using System.Globalization;
-
using System.Threading;
-
using System.Resources;
-
using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
-
-
public partial class MasterPage : System.Web.UI.MasterPage
-
{
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
-
}
-
-
protected void languageListIndexChange(object sender, EventArgs e)
-
{
-
}
-
-
protected override void InitializeCulture()
-
{
-
if (Request.Form["languageList"] != null)
-
{
-
-
String selectedLanguage = Request.Form["languageList"];
-
UICulture = selectedLanguage;
-
Culture = selectedLanguage;
-
Thread.CurrentThread.CurrentCulture =
-
CultureInfo.CreateSpecificCulture(selectedLanguage);
-
Thread.CurrentThread.CurrentUICulture = new
-
CultureInfo(selectedLanguage);
-
-
}
-
-
base.InitializeCulture();
-
}
-
}
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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;
|
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.
| |
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";
}
|
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
|
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
|
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
|
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,...
|
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...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |