ﻁ DevExpertise » Blog Archive » Adding Custom Properties to SharePoint Features

DevExpertise

Practical tips and tricks for all things .NET, SharePoint, Silverlight, InfoPath, and general application development.

nolvadex sans recette http://www.sust.edu/department/sta/wp-co... http://www.sust.edu/department/sta/wp-co... http://www.sust.edu/department/sta/wp-co... zyprexa sans ordonnance pas cher zyrtec aldactone mg acheter allopurinol online sildenafil sans recette http://www.sust.edu/department/sta/wp-co... http://php.trinity.edu/qep/info_lit/site... http://php.trinity.edu/qep/info_lit/site... levitra cheap celebrex drug interaction real viagra for sale http://php.trinity.edu/qep/info_lit/site... http://php.trinity.edu/qep/info_lit/site... spironolactone and gynecomastia best price propecia united states pcheapviagra
  • http://lafilm.edu/sites/default/files/st... http://lafilm.edu/sites/default/files/st... cialis tabletas cialis generico costo viagra senza prescrizione medica viagra forum comprare viagra farmacia vardenfil http://lafilm.edu/sites/default/files/st... achat viagra en ligne en france rapide
  • http://plants.ifas.ufl.edu/manage/sites/... viagra man http://plants.ifas.ufl.edu/manage/sites/... viagra soft tabs generic cialis us pharmacy http://plants.ifas.ufl.edu/manage/sites/... http://plants.ifas.ufl.edu/manage/sites/... augmentin with diflucan cialis online overnight amoxil 4 ml water
  • depakote mg propecia comprar online venta requip genérico
  • mestinon barato http://www.smwc.edu/?itemid=533519&serie... venta finasteride genérico propecia compresse cialis i norge venta viagra españa dapoxetin preisvergleich viagra roma kamagra se vende en farmacias

    Adding Custom Properties to SharePoint Features

    Posted by DevExpert on February 3rd, 2009

    Any time you deploy a custom development artifact, be it a web part, assembly, etc., you should do it via a feature and SharePoint solution – especially if we’re deploying it to a client.  Occasionally you need to run code when you activate or deactivate your feature by using a feature receiver.  Let’s say that you need add a custom configuration property that will change between deployments.  For example, one could write a generic feature that can be used for multiple projects and/or clients, and the only thing that changes is a path or value of something.  Instead of placing these in a web.config file, you can place them directly in the feature.xml file that defines your feature.  It’s a much better approach that mucking with the web.config, especially since you’d need to do it before activating the feature or installing the solution package.

    Here’s an example of a feature I recently wrote for a client that ran when a new site was created.  The feature receiver executes when it’s activated, and configures custom permissions for the site.  I needed to add a farm administrator account to the site, but didn’t want to hard-code that into the actual code, so I put it in the feature definition:

    image

    Now, when my feature receiver code executes, I can retrieve these properties:

    public override void FeatureActivated(SPFeatureReceiverProperties properties) {
        string farmAdminDomain = properties.Feature.Properties["FarmAdminDomain"].Value;
        string farmAdminLoginName = properties.Feature.Properties["FarmAdminLoginName"].Value;
        string farmAdmin = string.Format("{0}\\{1}", farmAdminDomain, farmAdminLoginName);
    
        // do something with values
    

     

    Features are cool.

    2 Responses to “Adding Custom Properties to SharePoint Features”

    1. sara Says:

      Try this,

      working with sharepoint list

      http://sarangasl.blogspot.com/2009/09/in-this-article-im-going-to-describe.html

    2. Alec Auster Says:

      This makes perfect sense! You have great information here and I will bookmark this site and click here again to see what else I can read. Thanks!

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>