I've created a new web part in a sandbox solution. This web part has a custom string property called 'PetName'.
I'd expect to be able to set the initial value of this property in the .webpart file. While this works perfectly in a Farm solution, in a Sandbox solution it does not. The field shows in the web part properties on the UI, but it is blank. I am able to persist a value if I enter a value into the field and click OK.
Does anyone have any idea how to manage this? I'm stumped.
Thanks, Dave
DumbWebPart.cs:
namespace MyDumbWebPart.DumbWebPart
{
[ToolboxItemAttribute(false)]
public class DumbWebPart : WebPart
{
[WebBrowsable(true), Personalizable(PersonalizationScope.Shared)]
public string PetName
{
get;
set;
}
protected override void CreateChildControls()
{
}
}
}
DumbWebPart.webpart
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="MyDumbWebPart.DumbWebPart.DumbWebPart, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">MyDumbWebPart - DumbWebPart</property>
<property name="Description" type="string">My Web Part</property>
<property name="PetName" type="string">Fluffy</property>
</properties>
</data>
</webPart>
</webParts>