Monday, October 4, 2010

Storing Feature Values in Feature.XML file

Ever created a feature and wanted to deploy it on multiple servers without hard coding certain values?

It's kind of easy, you can use the feature.xml, namely the properties section to save values that you might want to change in future and then access them through code later, or even change them if need be.

In your feature.xml file, create a properties section, and add property tags for the relevant properties as shown below:

If you want to access this property you created you can do so by using the following code:

string _property = properties.Feature.Properties["SiteURL"].Value;

And that's it, how to access values stored in the feature.xml file.

No comments:

Post a Comment