Webpart, Properties and default value

Webpart, Properties and default value

If you write a Webpart with custom properties, you have to take care of the default value.

[WebBrowsable(true),
DefaultValue("value"),
Personalizable(true),
WebDisplayName("some property"),
WebDescription("Description of the property")]
public
string PropertyName
{
get { return _ PropertyName; }
set { _ PropertyName = value; }
}

Please do not specify a default value, which you might actually use. The default property value will not be saved, if you choose to configure it with the default value!

Leave a Reply