Thursday, September 10, 2009

SharePoint WebPart | Unexpected Error

So you want to create a new web part with custom editable controls in "Modify Shared Web Part" area

An unexpected error has occurred.

Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.
Troubleshoot issues with Windows SharePoint Services.

- Add constructor to editor file, with ID
- Make sure your CreationEditorParts() method is returning something
- Make sure you add IWebEditable to header and implement the functions

public class MyWebPart: System.Web.UI.WebControls.WebParts.WebPart, IWebEditable

/* editor part */

public MyEditorPart()
this.ID = "MyEditorPart";
this.Title = "My Editor Title";

/* main webpart */

#region IWebEditable Members
EditorPartCollection IWebEditable.CreateEditorParts()
List editors = new List();

MyEditorPart slideShowEditor = new MyEditorPart();
return new EditorPartCollection(editors);
return new EditorPartCollection();

object IWebEditable.WebBrowsableObject
get { return this; }


No comments:

Post a Comment