none
How to create basic Sharepoint 2010 feature in Visual Studio 2010?

    Question

  • Hi,

    I played a lot with Visual Studio 2010 Beta and SharePOint 2010. I tried to change a lot in xml files provided out-of-box. But I can not find how to create simple feature in Visual Studio 2010 for Sharepoint 2010.  There are lot dependency on the out-of-box xml files, if we select some Sharepoint project types in VS 2010.

    I would like to know step-by-step, how to create simple feature to chage site title with the help of Feature receiver class help. How and where to add Feature receiver class entry in xml file. Whare is the feature.xml file in out of box.

    Friday, March 05, 2010 11:15 AM

Answers

  • It is a very easy process

    You can create a new Empty SharePoint project from VS 2010. Make sure you use the farm solution.
    After you have created your project, right click on the "Features" node in "solution explorer" and "add feature"
    This will create a new feature with the title "Feature1". You can rename it or leave it as it is.
    If you double click the name of the feature, you will get the properties of the feature, such as title, description and the scope.

    If you right click on the "feature1" in solution explorer, you can click on "Add feature Receiver"

    After the file has been created, uncomment (as required) the "on activate" and/or on "deactivate" and put your code in there. For example if you want to change the title of the site then you would have something like

    SPWeb contextWeb = (SPWeb)properties.Feature.Parent;
    contextWeb.Title += " Modifed by feature";
    contextWeb.Update();
    


    This is very basic one, you could actually save the old title, so you can reset it when the feature is deactivated.

    Here is a link to more resources to get you started

    Friday, March 05, 2010 1:50 PM

All replies

  • It is a very easy process

    You can create a new Empty SharePoint project from VS 2010. Make sure you use the farm solution.
    After you have created your project, right click on the "Features" node in "solution explorer" and "add feature"
    This will create a new feature with the title "Feature1". You can rename it or leave it as it is.
    If you double click the name of the feature, you will get the properties of the feature, such as title, description and the scope.

    If you right click on the "feature1" in solution explorer, you can click on "Add feature Receiver"

    After the file has been created, uncomment (as required) the "on activate" and/or on "deactivate" and put your code in there. For example if you want to change the title of the site then you would have something like

    SPWeb contextWeb = (SPWeb)properties.Feature.Parent;
    contextWeb.Title += " Modifed by feature";
    contextWeb.Update();
    


    This is very basic one, you could actually save the old title, so you can reset it when the feature is deactivated.

    Here is a link to more resources to get you started

    Friday, March 05, 2010 1:50 PM
  • Here's a how to video:
    http://www.sptechdives.com/?p=185
    Friday, March 05, 2010 1:51 PM
  • Thnks, Ninos Yacoub.

    Basically I had succesfully created custom Site Definition, MAster Page, Theme, Silverlight webpart, but I was struggling with basic feature. And now you have clear my doubt. thanks a lot!!!. Actually I was trying to add class file for feature receiver in project level.
    Monday, March 08, 2010 7:40 AM
  • Thnks, Ninos Yacoub.

    Basically I had succesfully created custom Site Definition, MAster Page, Theme, Silverlight webpart, but I was struggling with basic feature. And now you have clear my doubt. thanks a lot!!!. Actually I was trying to add class file for feature receiver in project level.
    Not a problem
    Monday, March 08, 2010 9:33 PM
  • Hi Ninos,

    I might be late comers in this blog. But it's really nice article for me to understand. As per your this post, We can change the title of the page using SharePoint Feature created from Visual Studio.

    I just want to know how would we can create such thing ? because other most of the articles (on Feature Activation Part) is showing to add new link in Site Action or such area.. but now showing how to hide/ change the title or view for the Task/List.

    Can we achieve the same using Visual Studio - SharePoint Feature ? Can you please let me know the link / video to refer in context of this requirement?

    Regards,
    Brijesh Shah


    Thanks & Regards, Brijesh Shah

    Wednesday, February 08, 2012 2:55 PM
  • Hi Ninos,

    I might be late comers in this blog. But it's really nice article for me to understand. As per your this post, We can change the title of the page using SharePoint Feature created from Visual Studio.

    I just want to know how would we can create such thing ? because other most of the articles (on Feature Activation Part) is showing to add new link in Site Action or such area.. but now showing how to hide/ change the title or view for the Task/List.

    Can we achieve the same using Visual Studio - SharePoint Feature ? Can you please let me know the link / video to refer in context of this requirement?

    Regards,
    Brijesh Shah


    Thanks & Regards, Brijesh Shah

    Wednesday, February 08, 2012 2:55 PM
  • If you have a question you should start your own question thread rather than asking it in a two year old, already answered, only loosely related thread.
    Wednesday, February 08, 2012 3:14 PM