Microsoft.SharePoint.WebPartPages.ToolPart missing on sandboxed solution.

Today, i am need to develop one webpart that i after completed deploy on  my on premise sharepoint site then i have to deploy it also to development server on Sharepoint Online Office 365.

The main goal is to deploy to Sharepoint Online Office 365. So after  searching how to create a webpart for Sharepoint Online Office 365, so i decided to create a webpart with type a sandbox solution.

For now, i guess this is  the only choice that i have, yes and we know it that Microsoft one day it will shutting down the sandbox solution but currently this the only solution.

Okay, back to code again… trying to create toolpart and found that Microsoft.SharePoint.WebPartPages.ToolPart is missing on on sandboxed solution.

So what we can do is we replace System.Web.UI.WebControls.WebParts.EditorPart 

Here as below the code that i written :

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Reflection;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using RoomBooking.RoomBookingWebpart;

namespace RoomBooking
{
public class EditorPartAbout : System.Web.UI.WebControls.WebParts.EditorPart
{
private LiteralControl _lc;

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

_lc = new LiteralControl();

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(“<table border=\”0\” width=\”100%\” ID=\”Table1\” align=\”left\”>”);
sb.AppendFormat(“<tr><td width=\”15%\” nowrap>Author</td><td>{0}</td></tr>”, “Agusto Xaverius”);
sb.AppendFormat(“<tr><td width=\”15%\” nowrap>Version</td><td>{0}</td></tr>”, this.GetVersionAssembly());
sb.Append(“</table>”);
_lc.Text = sb.ToString();
sb = null;
}

protected override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.Add(new LiteralControl(“About :<br/>”));
this.Controls.Add(_lc);
this.Controls.Add(new LiteralControl(“<br/>”));
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}

public override bool ApplyChanges()
{
RoomBooking.RoomBookingWebpart.RoomBookingWebpart webPart = this.WebPartToEdit as RoomBooking.RoomBookingWebpart.RoomBookingWebpart;
if (webPart != null)
{
webPart._editorPartAbout = _lc.Text;
}
return true;
}

public override void SyncChanges()
{
RoomBooking.RoomBookingWebpart.RoomBookingWebpart webPart = this.WebPartToEdit as RoomBooking.RoomBookingWebpart.RoomBookingWebpart;
if (webPart != null)
{
_lc.Text = webPart._editorPartAbout;
}
}

private string GetVersionAssembly()
{
Assembly ass = Assembly.GetExecutingAssembly();
AssemblyName an = ass.GetName();
return String.Format(“{0}.{1}”, an.Version.Major.ToString(), an.Version.Minor.ToString());
}
}
}

Happy Sharepoint-Ing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.