If you're using the Get/SetDetail syntax then you can do something like this in the property getter:
public virtual string TopImage
{
get { return (string)(GetDetail("TopImage") ?? string.Empty); }
set { SetDetail("TopImage", value); }
}
That's a bit ugly, so there's also an overload for Get/Set detail that lets you specify the default:
public virtual string TopImage
{
get { return GetDetail("TopImage", String.Empty /* Default */); }
set { SetDetail("TopImage", value, String.Empty /* Default */); }
}
If you want to save a value when something is saved then try overriding the AddTo
method on the ContentItem. This is called every time the object is saved, so be careful if you only want to call it the first time something is saved (ID == 0 when an Item is "new")