views:

4131

answers:

4

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.

A: 

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

Jason
I have changed and it didn't help.
iulianchira
+5  A: 

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; }
Rob Windsor
Thank you. I spent an entire day trying to solve this problem.
iulianchira
+3  A: 

@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; }
    }
program247365
A: 

Hi,

I'm having a similar problem: I'm extending the Content Query Web Part and trying to add a custom property to it. Here is the code:

namespace NewCQWP
{
    [DefaultProperty("ReadMoreText"), ToolboxData("<{0}:CustomizedWebPart  runat=server></{0}:CustomizedWebPart>"), XmlRoot(Namespace = "CustomizedWebPart")]
    [Guid("1695298c-38ac-4911-813c-65ba26892d15")]
    public class WebPart1 : ContentByQueryWebPart
    {
        private string readmoretext;

        [WebBrowsable(true), WebDisplayName("Read More Text"), WebPartStorage(Storage.Personal),
        WebDescription("Label"), Personalizable(PersonalizationScope.User)]
        public string ReadMoreText
        {
            get { return readmoretext; }  set { readmoretext = value; }
        }
    }
}

The property ReadMoreText doesn't show up in the properties toolbox. Can the problem be the XmlRoot property? Is it something related to extending the ContentByQueryWebPart? Something else?

JPequenao