0

I have created a web part in SharePoint 2007 which has over 40 controls and I was able to make two different Tool Part classes to hold the different sections of the custom controls. I am converting the part over to SharePoint 2010, and I am having a hard time getting two EditorPartCollection class to work on the same page. How can I have two of these? I am sure it is possible, I am just having a hard time getting this to work. Any help would be appreciated.

 public override EditorPartCollection CreateEditorParts()
    {
        var editor = new ClockEditor
        {
            ID = ID + "_Editor",
            Title = "Custom Clock Editor"
        };
        return new EditorPartCollection(new EditorPart[] { editor });
    }


    public override EditorPartCollection CreateEditorParts()
    {
        var zoneEditor = new ZoneEditor
        {
            ID = ID + "_Editor",
            Title = "Time Zone Editor"
        };
        return new EditorPartCollection(new EditorPart[] { zoneEditor });
    } 
1
  • Try EditorPartCollection(ICollection editorParts);
    – user21028
    Commented Nov 26, 2013 at 13:03

1 Answer 1

1

See if this works:

public override EditorPartCollection CreateEditorParts()
{
    var zoneEditor = new ZoneEditor
    {
        ID = ID + "_Editor",
        Title = "Time Zone Editor"
    };
    var editor = new ClockEditor
    {
        ID = ID + "_Editor",
        Title = "Custom Clock Editor"
    };
    return new EditorPartCollection(new EditorPart[] { editor, zoneEditor });
} 
2
  • I tried that and it did not seem to work right. i do not think I did the return new EditorPartCollection(new EditorPart[] { editor, zoneEditor }); part right I am going to try again thanks. I have for now just loaded all of the controls into the one editor part. I really do not want to do this because I have so many controls. It has been much neater to keep them separate. Thanks for the suggestion.
    – lazoDev
    Commented Sep 11, 2012 at 17:56
  • That is it. Thanks. I was trying to return two instances of the EditorPartCollection and that is why it was not working. Thank you. I knew there had to be a way I was overlooking. +1
    – lazoDev
    Commented Sep 11, 2012 at 18:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.