Sharepoint custom web part property does not show up in the toolbox

孤者浪人 提交于 2019-12-12 08:22:01

问题


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.


回答1:


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; }



回答2:


@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; }
    }



回答3:


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



来源:https://stackoverflow.com/questions/616490/sharepoint-custom-web-part-property-does-not-show-up-in-the-toolbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!