Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm adding some functionality to the ContentQueryWebPart by inheriting from ContentByQueryWebPart... but when I try and add a new WebPart Property, the actual field does not show up when I edit the webpart! Has anyone else tried this?

Here is an example of a property I am trying to add:

   [WebBrowsable(true), Personalizable(PersonalizationScope.Shared),     WebDisplayName("Page Filter Field"), 
    WebDescription("Enter the Page Field name which the CQWP will filter on"),
    SPWebCategoryName("CategoryConfigureQuery")]

    public string PageFilterField
    {
        get
        {
            return _pageFilterField;
        }

        set
        {
            _pageFilterField = value;
        }
    }
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to add a customised ToolPart for your property

public class CustomWebPart : ContentByQueryWebPart {
    public override ToolPart[] GetToolParts() {
        List<ToolPart> result = new List<ToolPart>(base.GetToolParts());
        result.Add(new YourCustomToolPart());
        return result.ToArray();
    }
}

And for the ToolPart see here

http://msdn.microsoft.com/en-us/library/dd584178(office.11).aspx

share|improve this answer
    
Perfect!! Thanks for leading me down the right track. I used this link as an example to get my properties showing up: zimmergren.net/archive/2008/11/29/… –  user424 Jan 17 '11 at 2:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.