【问题标题】:How to localize WebParts attributes within the PropertyEditorPart?如何在 PropertyEditorPart 中本地化 WebParts 属性?
【发布时间】:2011-04-27 14:45:39
【问题描述】:

有没有办法本地化显示在PropertyEditorPart 中的文本?

[Personalizable(true),
WebBrowsable(true),
WebDisplayName("To Date: "),
WebDescription("Please enter To Date value.")]
public string ToDate
{
    get { return toDate; }
    set { toDate = value; }
}

【问题讨论】:

    标签: asp.net localization web-parts


    【解决方案1】:

    为实现这一点,应扩展这些属性(Category、WebDisplayName 和 WebDescription),以便它们利用本地化功能。

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
     public sealed class LocalizedWebDisplayNameAttribute
         : WebDisplayNameAttribute {
    
         bool m_isLocalized ;
    
         public LocalizedWebDisplayNameAttribute(string displayName)
             : base(displayName) {
         }
    
         public override string DisplayName {
             get {
                 if (!m_isLocalized) {
                     this.DisplayNameValue = 
                         Resources.ResourceManager.GetString(
                             base.DisplayName, Resources.Culture);
                     m_isLocalized = true;
                 }
                 return base.DisplayName;
             }
         }
     }
    

    更多详情,Web Part Properties - part 5 - localization

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多