【问题标题】:How to set EditorPart header in SharePoint WebParts?如何在 SharePoint WebParts 中设置 EditorPart 标头?
【发布时间】:2012-04-05 00:58:17
【问题描述】:

我正在尝试为自定义编辑器部件部分设置标题。有什么想法吗?

【问题讨论】:

    标签: sharepoint web-parts


    【解决方案1】:

    EditorPart 类:

    public class YourCustomEditorPart:System.Web.UI.WebControls.WebParts.EditorPart{
       protected override void CreateChildControls() {
          this.Title = "Editor Part Title Here";
          ...
       }
    }
    

    告诉 Web 部件它应该使用此编辑器部件,而不是属性属性。

    WebPart 类:

    public class YourWebPart:System.Web.UI.WebControls.WebParts.WebPart, IWebEditable {
    ...
    EditorPartCollection IWebEditable.CreateEditorParts() {
        // control the editorparts
        List<EditorPart> editors = new List<EditorPart>();
        YourCustomEditorPart editorPart = new YourCustomEditorPart();
        editorPart.ID = this.ID + "_editorPart";
        editors.Add(editorPart);
        return new EditorPartCollection(editors);
        }
    ...
    }
    

    查看以下系列了解详情。 (包括下载源代码)

    http://www.wictorwilen.se/Post/Web-Part-Properties-part-1-introduction.aspx

    http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx

    【讨论】:

    • 答案有帮助,但不幸的是我还不能投票,因为我没有足够的积分作为声誉:(
    • 我应该在上一篇文章中感谢你,迟到最好不要。谢谢 MinMin :) 还有一个问题,在标题部分 TweetPart 属性中,最小化图标在右侧,与内置的“+”不同。有什么方法可以实现吗?
    • 标题标题的 HTML 标记和 css 是从 EditorPart 类生成的。可能您可以覆盖此类的默认外观。我不知道。如果您想探索更多,请查看此文档。 (msdn.microsoft.com/en-us/library/…)。如果您有像“IE 开发工具栏”这样的工具来分析页面中的 css 和 html,那将非常有帮助。
    • 再次感谢敏敏。感谢您花费时间和精力帮助我。
    • @bkk 你有没有发现如何操作标题的样式?我希望以与其他类别相同的方式设置标题的样式。
    猜你喜欢
    • 2011-10-13
    • 2010-11-27
    • 2017-12-08
    • 2015-12-03
    • 2023-03-30
    • 2010-11-04
    • 2018-06-21
    相关资源
    最近更新 更多