How to access SharePoint web part properties?

Posted by shannon.stewart on Stack Overflow See other posts from Stack Overflow or by shannon.stewart
Published on 2010-04-16T18:39:18Z Indexed on 2010/04/16 18:43 UTC
Read the original article Hit count: 292

Filed under:
|

I have created a feature for SharePoint 2007 that has a web part. I have added a custom property to the web part like so:

[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[Category("My Custom Properties")]
[WebDisplayName("ServiceURL")]
[WebDescription("The URL for the Wcf service")]
public string ServiceURL { get; set; }

Along with this web part, I've added a custom page that the web part will have a link to. I would like to reference the web part property from the custom page, but I don't know where these properties are stored. I've tried to access it using the code below, but both property collections don't have any properties stored.

SPFeaturePropertyCollection spProperties = SPContext.Current.Site.Features[this.FeatureGuid].Properties;

or

SPFeaturePropertyCollection spProperties = SPContext.Current.Site.Features[this.FeatureGuid].Definition.Properties;

My question is how can I get a reference to the web part property from other pages?

© Stack Overflow or respective owner

Related posts about sharepoint2007

Related posts about webparts