Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7013359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:22:36+00:00 2026-05-27T22:22:36+00:00

I cant use the following code in Master page for Globalization & Localization. It

  • 0

I cant use the following code in Master page for Globalization & Localization. It gives the error as commented in the code part “does not contain a defination for InitializeCulture”

   protected override void InitializeCulture()
    {
        if (Request["Language"] != null)
        {
            //String selectedLanguage = Request["Language"];
           // code wil go here

        }
        base.InitializeCulture();
       //base.InitializeCulture gives error as mentioned in the next line
       //does not contain a defination for InitializeCulture
    }

When i add this code to other pages other than Master Page it works fine. is there any restriction on using this code in Master Page.

If i am able to define this code in Master Page then i dont need to write this code in every file.

Am i doing something wrong, I have include File for threading and Globalization, Still it doesn’t work in Master Page

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:22:37+00:00Added an answer on May 27, 2026 at 10:22 pm

    You have to do this (= override InitializeCulture) in your Page class. It doesn’t work in the master page (MasterPage is derived from Control, not from page). I would suggest that you implement a base class which is derived from Page and derive every web form from this class, then you also have to write the code only once. It is always handy to have your own base class.

    In Visual Studio you add a new class PageBase.cs:

    public class FormBase : Page
    {
       protected override InitializeCulture()
       {
          if (Request.Form["lbCulture"] != null)
          {
             String selectedLanguage = Request.Form["lbCulture"];
             UICulture = selectedLanguage;
             Culture = selectedLanguage;
    
             Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
             Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage);
          }
          base.InitializeCulture();
       }
    }
    

    The current culture is either stored in some dropdown listbox, in the session or passed by query string. I used a listbox in the sample.

    And then you derive your WebForm from this page like this:

    public class Default : FormBase // instead of deriving from Page
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why cant i use code nuggets to set a control property??For example a validationgroup
i have lots of videos in my server and i use the following code
The following code works great in IE, but not in FF or Safari. I
I'm trying to use the following code so when a person clicks on a
I know that we cant use assignment operator in if statements in java as
i am using diaply tags library for displaying my tables.But i cant use the
we use an external Database where we cant edit table designs only add own
I use TcxGrid But I cant create fields on execution time because I have
Can anyone explain why you can’t use inline code blocks within server control declarations
I have a user control which contains the following code: <form id=CurrencyForm method=post runat=server>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.