Sharepoint 自定义 Web 部件属性未显示在工具箱中

发布于 2024-07-14 18:54:28 字数 315 浏览 9 评论 0原文

我定义了一个布尔属性,如下所示:

 [Browsable(true), Category("Display"), DefaultValue(false),
  WebPartStorage(Storage.Shared), FriendlyName("Obey Workflow"),
  Description("")]
  public bool ObeyWorkflow { get; set; }

我希望它在 Web 部件的属性工具箱中呈现为复选框,但它没有显示。 我的 Web 部件派生自 Sharepoint WebPart 基类。

I have defined a boolean property as follows:

 [Browsable(true), Category("Display"), DefaultValue(false),
  WebPartStorage(Storage.Shared), FriendlyName("Obey Workflow"),
  Description("")]
  public bool ObeyWorkflow { get; set; }

I'm expecting it to render as a checkbox in the webpart's properties toolbox, however it doesn't show up. My web part is derived from the Sharepoint WebPart base class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苍景流年 2024-07-21 18:54:28

你走在正确的轨道上。 您只需要使用不同的属性即可。

[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[Category("Display")]
[WebDisplayName("Obey Workflow")]  
[Description("")]  
public bool ObeyWorkflow { get; set; }

You are on the right track. You just need to use different attributes.

[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[Category("Display")]
[WebDisplayName("Obey Workflow")]  
[Description("")]  
public bool ObeyWorkflow { get; set; }
喵星人汪星人 2024-07-21 18:54:28

@Jason,你是对的。 语法“Browsable”和“Category”是Sharepoint 2003 特定的。 对于 SharePoint 2007,它分别是“WebBrowsable”和“SPWebCategoryName”。

DefaultValue(false) 也是 SharePoint 2003 特定的。

据我所知,2007 年的情况是预先声明它,如下所示:

    private string _strMainFolder = "Reports"; //Here is the default value

    [WebBrowsable(true)]
    [WebDisplayName("SharePoint List Name")]
    [SPWebCategoryName("SharePoint List Name Settings")]
    [WebPartStorage(Storage.Shared)]
    [WebDescription("You would put the description here.")]
    [Personalizable(PersonalizationScope.Shared)]
    public string strMainFolder
    {
        get { return _strMainFolder; }
        set { _strMainFolder = value; }
    }

@Jason, you're correct. The syntax "Browsable", and "Category" are Sharepoint 2003 specific. For SharePoint 2007, it's "WebBrowsable", and "SPWebCategoryName" respectively.

DefaultValue(false) is also SharePoint 2003 specific.

The equivalent in 2007, as far as I know, is to declare it initially beforehand, like this:

    private string _strMainFolder = "Reports"; //Here is the default value

    [WebBrowsable(true)]
    [WebDisplayName("SharePoint List Name")]
    [SPWebCategoryName("SharePoint List Name Settings")]
    [WebPartStorage(Storage.Shared)]
    [WebDescription("You would put the description here.")]
    [Personalizable(PersonalizationScope.Shared)]
    public string strMainFolder
    {
        get { return _strMainFolder; }
        set { _strMainFolder = value; }
    }
卸妝后依然美 2024-07-21 18:54:28

我认为它是 WebBrowsable(true) 而不是 Browsable(true)

i think its WebBrowsable(true) instead of Browsable(true)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文