SharePoint 2007公共覆盖ToolPart [] GetToolParts()错误?

时间:2013-08-08 14:37:32

标签: sharepoint-2007 content-query-web-part toolpart

在此自定义内容查询Web部件中,以下代码有效。我可以更改Web部件标题和ToolPart标题:

public class CustomWebPart1 : ContentByQueryWebPart
{
    public override ToolPart[] GetToolParts()
    {
        ToolPart[] toolPartArray = base.GetToolParts();
        return new ToolPart[] { new CustomContentQueryWebPartToolPart(), toolPartArray[0], toolPartArray[1] };
    }
}

public class CustomContentQueryWebPartToolPart : ToolPart
{
    TextBox txt1;
    CustomWebPart1 wp;

    public CustomContentQueryWebPartToolPart()
    {
        this.Title = "My Custom Properties";
    }

    protected override void CreateChildControls()
    {
        txt1 = new TextBox();
        this.Controls.Add(txt1);

        base.CreateChildControls();
    }

    public override void ApplyChanges()
    {
        this.Title = "ToolPart Title: " + txt1.Text;

        wp = this.WebPartToEdit as CustomWebPart1;

        wp.Title = "WebPart Title: " + txt1.Text;

        base.ApplyChanges();
    }
}

enter image description here

但是,如果我更改数组中的位置(这是Web部件属性的显示顺序),更改Web部件标题将不再起作用!

    public override ToolPart[] GetToolParts()
    {
        ToolPart[] toolPartArray = base.GetToolParts();
        return new ToolPart[] { toolPartArray[0], toolPartArray[1], new CustomContentQueryWebPartToolPart() };
    }

enter image description here

这里有什么问题?这是一个错误吗?更改ToolPart标题仍然有效。

0 个答案:

没有答案