I want to implement the custom EditorPart in SharePoint sandboxed solution. I have the code like below. When I deploy the solution I cannot see the textbox and I noticed that the code is not executing.No controls are added in the toolpane . Can anyone tell me what I am missing or where have I gone wrong?
public class CustomProperty : EditorPart
{
TextBox _tbTaskList;
public CustomProperty()
{
Title = "Custom WebPart Settings";
}
public override bool ApplyChanges()
{
CustomWebPart part = (CustomWebPart)WebPartToEdit;
//Update the custom WebPart control with the task list
part.taskList = tbTaskList.Text;
return true;
}
public override void SyncChanges()
{
CustomWebPart part = (CustomWebPart)WebPartToEdit;
String currentList = part.taskList;
}
protected override void CreateChildControls()
{
Controls.Clear();
//Add a new textbox control to set the task list
_tbTaskList = new TextBox();
Controls.Add(_tbTaskList);
}
protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write("List Name :");
writer.WriteBreak();
_tbTaskList.RenderControl(writer);
writer.WriteBreak();
}
private TextBox tbTaskList
{
get
{
EnsureChildControls();
return _tbTaskList;
}
}
}
CustomWebPart is the webpart name. the webpart class conatins:
public class CustomWebPart: System.Web.UI.WebControls.WebParts.WebPart
{
public override object WebBrowsableObject
{
get
{
return this;
}
}
private String _taskList = null;
[Personalizable(), WebBrowsable()]
public String taskList
{
get { return _taskList; }
set { _taskList = value; }
}
public override EditorPartCollection CreateEditorParts()
{
ArrayList editorArray = new ArrayList();
CustomProperty edPart = new CustomProperty();
edPart.ID = this.ID + "_editorPart1";
editorArray.Add(edPart);
EditorPartCollection editorParts = new EditorPartCollection(editorArray);
return editorParts;
}
}
And my VisualWebaprt(sandboxed) class file contains:
[ToolboxItem(false)]
public partial class VisualWebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
}
}