代码之家  ›  专栏  ›  技术社区  ›  Ahmed Atia

如何在PropertyEditorPart中本地化WebParts属性?

  •  0
  • Ahmed Atia  · 技术社区  · 14 年前

    PropertyEditorPart ?

    [Personalizable(true),
    WebBrowsable(true),
    WebDisplayName("To Date: "),
    WebDescription("Please enter To Date value.")]
    public string ToDate
    {
        get { return toDate; }
        set { toDate = value; }
    }
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   Ahmed Atia    14 年前

    为了实现这一点,应该扩展这些属性(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