0

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

1 Answer 1

1

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

1
  • 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, 2011 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.