masterpage initializeculture no suitable method found to override error?

后端 未结 2 1802
离开以前
离开以前 2020-12-30 08:06

I\'m trying to develop a MultiLanguage web site using ASP.NET with C# My problem is: I want to make my MasterPage support switching among languages, but when i put the \"Ini

2条回答
  •  再見小時候
    2020-12-30 08:13

    The method InitializeCulture() exists only on the Page class, not the MasterPage class, and that's why you get that error.

    To fix this, you could create a BasePage that all your specific pages inherit:

    1. Create a new Class (not Webform), call it BasePage, or whatever you want.
    2. Make it inherit System.Web.UI.Page.
    3. Make all your other pages inherit the BasePage.

    Here's an example:

    public class BasePage : System.Web.UI.Page
    {
        protected override void InitializeCulture()
        {
            //Do the logic you want for all pages that inherit the BasePage.
        }
    }
    

    And the specific pages should look something like this:

    public partial class _Default : BasePage //Instead of it System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Your logic.
        }
    
        //Your logic.
    }
    

提交回复
热议问题