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

  • Home
  • SEARCH
  • 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 3675312
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:57:38+00:00 2026-05-19T02:57:38+00:00

I am extending the asp.net resource provider. The problem is the extended resource provider

  • 0

I am extending the asp.net resource provider.
The problem is the extended resource provider is not detecting the page culture.
The CultureInfo in the GetObject() method is always null.

To change the page culture i am using a listbox an overriding InitializeCulture():

protected override void InitializeCulture()
        {
            if (Request.Form["ListBox1"] != null)
            {
                String selectedLanguage = Request.Form["ListBox1"];
                UICulture = selectedLanguage;
                Culture = selectedLanguage;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage);
            }
            base.InitializeCulture();
        }

And the GetObject() function:

public object GetObject(string resourceKey, CultureInfo culture)
        {
            //Call of the data access layer function to retreave the resource value from the database
            string resourceValue = m_dalc.GetResourceByCultureAndKey(culture, resourceKey);

            return resourceValue;
        }

This is the Resource Provider class:

public class DBResourceProvider : IResourceProvider
    {
        #region local variables

        //We save the classKey (resourceType) in this variable
        private string m_classKey;

        //New instance of the data access layer
        private StringResourcesDALC m_dalc;

        #endregion

        #region Constructors

        /// <summary>
        /// Constructor that creates a new instance of a resource provider using the resource type
        /// </summary>
        /// <param name="classKey">Resource type</param>
        public DBResourceProvider(string classKey)
        {
            this.m_classKey = classKey;
            m_dalc = new StringResourcesDALC(classKey);
        }

        #endregion

        #region IResourceProvider Members

        /// <summary>
        /// Function that is called when we have explicit declarations of local and global resources
        /// </summary>
        /// <param name="resourceKey">Key of the resource</param>
        /// <param name="culture">Culture code</param>
        /// <returns>Resource value</returns>
        public object GetObject(string resourceKey, CultureInfo culture)
        {
            //Call of the data access layer function to retreave the resource value from the database
            string resourceValue = m_dalc.GetResourceByCultureAndKey(culture, resourceKey);

            return resourceValue;
        }

        //Property that returns a new resource reader used to get local resources wich have been declared implicitly
        public System.Resources.IResourceReader ResourceReader
        {
            get
            {
                //Call of the data access layer function that returns all resource keys and values for a single culture
                ListDictionary resourceDictionary = this.m_dalc.GetResourcesByCulture(CultureInfo.InvariantCulture);

                return new DBResourceReader(resourceDictionary);
            }

        }

        #endregion

    }

Thank you very much for your time.

  • 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-19T02:57:39+00:00Added an answer on May 19, 2026 at 2:57 am

    For the GetObject() method, it is not guaranteed that the current culture is provided by ASP.NET. Try the following:

    public object GetObject(string resourceKey, CultureInfo culture) {
        if (culture == null)
        {
            culture = CultureInfo.CurrentUICulture;
        }
    
        //Call of the data access layer function to retreave the resource value from the database
        string resourceValue = m_dalc.GetResourceByCultureAndKey(culture, resourceKey);
        return resourceValue;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am extending the default asp.net mvc example.. i am using asp.net membership provider
I am basically taking the default ASP.NET MVC template and extending it: Looking at
I understand the reason for having the HTML helpers in ASP.NET MVC and extending
I am working on extending an ASP.NET 2.0 application using an InterBase database. My
Are there any ways in ASP.net to fetch data from the server without extending
I'm building a web application using the ASP.net Membership Provider to manage, Authentication/Authorisation. I've
Say I'm extending a TextBox called CustomTextBox in .net. In certain situations I would
How does Rhino security gel with the asp.net membership providers? The reason why I
I am using ASP.Net 2.0. I am using a gridview component over some data
I have written an ASP.NET MVC application that runs inside an IFrame. When one

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.