• <legend id='vmI33'><style id='vmI33'><dir id='vmI33'><q id='vmI33'></q></dir></style></legend>

    <small id='vmI33'></small><noframes id='vmI33'>

      <bdo id='vmI33'></bdo><ul id='vmI33'></ul>
  • <tfoot id='vmI33'></tfoot>
    <i id='vmI33'><tr id='vmI33'><dt id='vmI33'><q id='vmI33'><span id='vmI33'><b id='vmI33'><form id='vmI33'><ins id='vmI33'></ins><ul id='vmI33'></ul><sub id='vmI33'></sub></form><legend id='vmI33'></legend><bdo id='vmI33'><pre id='vmI33'><center id='vmI33'></center></pre></bdo></b><th id='vmI33'></th></span></q></dt></tr></i><div id='vmI33'><tfoot id='vmI33'></tfoot><dl id='vmI33'><fieldset id='vmI33'></fieldset></dl></div>

        masterpage initializeculture 找不到合适的方法来覆盖错

        时间:2023-08-26
            <bdo id='cF82e'></bdo><ul id='cF82e'></ul>

                  <i id='cF82e'><tr id='cF82e'><dt id='cF82e'><q id='cF82e'><span id='cF82e'><b id='cF82e'><form id='cF82e'><ins id='cF82e'></ins><ul id='cF82e'></ul><sub id='cF82e'></sub></form><legend id='cF82e'></legend><bdo id='cF82e'><pre id='cF82e'><center id='cF82e'></center></pre></bdo></b><th id='cF82e'></th></span></q></dt></tr></i><div id='cF82e'><tfoot id='cF82e'></tfoot><dl id='cF82e'><fieldset id='cF82e'></fieldset></dl></div>

                  <small id='cF82e'></small><noframes id='cF82e'>

                  <legend id='cF82e'><style id='cF82e'><dir id='cF82e'><q id='cF82e'></q></dir></style></legend>
                    <tbody id='cF82e'></tbody>

                  <tfoot id='cF82e'></tfoot>
                • 本文介绍了masterpage initializeculture 找不到合适的方法来覆盖错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用带有 C# 的 ASP.NET 开发多语言网站我的问题是:我想让我的 MasterPage 支持语言之间的切换,但是当我将InitializeCulture()"放入 masterpage.cs 时,我得到了这个错误.

                  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 "InitializeCulture()" inside the masterpage.cs, I got this error.

                  这是我的代码:

                  public partial class BasicMasterPage : System.Web.UI.MasterPage
                  {
                  protected void Page_Load(object sender, EventArgs e)
                  {
                  
                  }
                  protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
                  {
                      if (e.Day.IsToday)
                      {
                          e.Cell.Style.Add("background-color", "#3556bf");
                          e.Cell.Style.Add("font-weight", "bold");
                      }
                  }
                  Dictionary<string, System.Globalization.Calendar> Calendars =
                      new Dictionary<string, System.Globalization.Calendar>()
                      {
                          {"GregorianCalendar", new GregorianCalendar()},
                          {"HebrewCalendar", new HebrewCalendar()},
                          {"HijriCalendar", new HijriCalendar()},
                          {"JapaneseCalendar", new JapaneseCalendar()},
                          {"JulianCalendar", new JulianCalendar()},
                          {"KoreanCalendar", new KoreanCalendar()},
                          {"TaiwanCalendar", new TaiwanCalendar()},
                          {"ThaiBuddhistCalendar", new ThaiBuddhistCalendar ()}
                      };
                  
                  protected override void InitializeCulture()
                  {
                      if (Request.Form["LocaleChoice"] != null)
                      {
                          string selected = Request.Form["LocaleChoice"];
                          string[] calendarSetting = selected.Split('|');
                          string selectedLanguage = calendarSetting[0];
                  
                          CultureInfo culture = CultureInfo.CreateSpecificCulture(selectedLanguage);
                  
                          if (calendarSetting.Length > 1)
                          {
                              string selectedCalendar = calendarSetting[1];
                              var cal = culture.Calendar;
                              if (Calendars.TryGetValue(selectedCalendar, out cal))
                                  culture.DateTimeFormat.Calendar = cal;
                          }
                  
                          Thread.CurrentThread.CurrentCulture = culture;
                          Thread.CurrentThread.CurrentUICulture = culture;
                      }
                      base.InitializeCulture();
                  }
                  }
                  

                  如何创建基类?

                  推荐答案

                  InitializeCulture()方法只存在于Page 类,而不是 MasterPage 类,这就是你得到这个错误的原因.

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

                  要解决这个问题,您可以创建一个 BasePage 让您的所有特定页面都继承:

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

                  1. 创建一个新类(不是 Webform),将其命名为 BasePage 或任何您想要的名称.
                  2. 使其继承System.Web.UI.Page.
                  3. 让所有其他页面继承 BasePage.
                  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.

                  这是一个例子:

                  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.
                  }
                  

                  这篇关于masterpage initializeculture 找不到合适的方法来覆盖错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:日历自定义验证器 下一篇:显示全年的 asp.net 可用性日历

                  相关文章

                  最新文章

                  1. <tfoot id='Vnfg5'></tfoot>
                    <i id='Vnfg5'><tr id='Vnfg5'><dt id='Vnfg5'><q id='Vnfg5'><span id='Vnfg5'><b id='Vnfg5'><form id='Vnfg5'><ins id='Vnfg5'></ins><ul id='Vnfg5'></ul><sub id='Vnfg5'></sub></form><legend id='Vnfg5'></legend><bdo id='Vnfg5'><pre id='Vnfg5'><center id='Vnfg5'></center></pre></bdo></b><th id='Vnfg5'></th></span></q></dt></tr></i><div id='Vnfg5'><tfoot id='Vnfg5'></tfoot><dl id='Vnfg5'><fieldset id='Vnfg5'></fieldset></dl></div>

                    <small id='Vnfg5'></small><noframes id='Vnfg5'>

                      <bdo id='Vnfg5'></bdo><ul id='Vnfg5'></ul>
                    <legend id='Vnfg5'><style id='Vnfg5'><dir id='Vnfg5'><q id='Vnfg5'></q></dir></style></legend>