如何在Property EditorPart中本地化Web部件属性?

时间:2010-10-19 17:06:49

标签: asp.net localization web-parts

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

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

1 个答案:

答案 0 :(得分:0)

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