SharePoint WebPart | Unexpected Error

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

ERROR:
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.



SOLUTION:
- 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()
{
try
{
List editors = new List();

MyEditorPart slideShowEditor = new MyEditorPart();
editors.Add(slideShowEditor);
return new EditorPartCollection(editors);
}
catch
{
return new EditorPartCollection();
}
}

object IWebEditable.WebBrowsableObject
{
get { return this; }
}
#endregion


SOURCE:
http://www.tonstegeman.com/Blog/Lists/Posts/Attachments/36/editorpart1_cced0bad340a4d51a650502eab149c6e.png

Comments

Popular posts from this blog

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes

Document ID not being generated