.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Asad Ali
Post New Web Links

accessing site name through feature activation.

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :SharePoint
 

HI,

I am currently using the site url to get the site to create Features. Below is the sample code:

[CODE]

  string strUrl = http://localhost:8099/sitename;

    using (SPSite site = new SPSite(strUrl))

    {

        using (SPWeb web = site.OpenWeb())

        {

}

}

[/CODE]

I would like to generalize the function. Currently, i am passing the server url and site name in the code as string variable. So when i activate the feature, the feature is activated for the site alone.

Is it possible to make the site as a generalised one. while activating feature through stsadm command, the site name is provided. Can the site name be taken from here for the code. That is in the site, i want to pass only the server url as site. when doing the activation, either way the site name will


View Complete Post


More Related Resource Links

Create site template wsp + Feature Activation: Cannot create folder

  

Hi,

I try to create a new site based with a site template previously saved in a wsp solution and I get the following error :

Feature Activation: Threw an exception, attempting to roll back. Feature 'OnBoarding29Modules' (ID: '8f57f818-8940-4c42-bc0d-2626c72a4553'). Exception: Microsoft.SharePoint.SPException: Cannot create folder "Workflows/OnBoardingNew/Lists/Discussion5/Attachments". ---> System.Runtime.InteropServices.COMException (0x81070203): <nativehr>0x81070203</nativehr><nativestack></nativestack>Cannot create folder "Workflows/OnBoardingNew/Lists/Discussion5/Attachments".  
 at Microsoft.SharePoint.Library.SPRequestInternalClass.EnableModuleFromXml(String bstrSetupDirectory, String bstrFeatureDirectory, String bstrUrl, String bstrXML, Boolean fForceUnghost, ISPEnableModuleCallback pModuleContext)  
 at Microsoft.SharePoint.Library.SPRequest.EnableModuleFromXml(String bstrSetupDirectory, String bstrFeatureDirectory, String bstrUrl, String bstrXML, Boolean fForceUnghost, ISPEnableModuleCallback pModuleContext)   -
 -- End of inner exception stack trace ---  
 at Microsoft.SharePoint.Administrati

Automating Site Creation and Feature Activation with PowerShell

  

I am trying to create a blank site and then loop through the available features for that site and activate them. The problem I am facing is the list of features scoped to "web" that are returned in powershell are not the same list of web features that are visible through the site settings in the SharePoint UI or through the SharePoint 2010 Manager UI.

What I get returned from Powershell is:

DisplayName Id

----------- --

WebPageLibrary 00bfea71-c796-4402-9f2f-0eb9a6e71b18

IssuesList 00bfea71-5932-4f9c-ad71-1557e5751100

WorkflowHistoryList 00bfea71-4ea5-48d4-a4ad-305cf7030140

NoCodeWorkflowLibrary 00bfea71-f600-43f6-a895-40c0de7b0117

SurveysList 00bfea71-eb8a-40b1-80c7-506be7590102

GridList 00bfea71-3a1d-41d3-a0ee-651d11570120

GanttTasksList 00bfea71-513d-4ca0-96c2-6a47775c0119

LinksList 00bfea71-2062-426c-90bf-714c59600103

MobilityRedirect f41cc668-37e5-4743-b4a8-74d1db3fd8a4

workflowProcessList 00bfea71-2d77-4a75-9fca-76516689e21a

TasksList 00bfea71-a83e-497e-9ba0-7a5c597d0107

TeamCollab 00bfea71-4ea5-48d4-a4ad-7ea5c011abe5

AnnouncementsList 00bfea71-d1ce-42de-9c63-a44004ce0104

ObaSimpleSolution d250636f-0a26-4019-8425-a5232d592c01

PictureLibrary 00bfea71-52d4-45b3-b544-b1c71b620109

ContactsList 00bfea71-7e6d-4186-9ba8-c047ac750105

Why do the aks master pages not get applied if the feature is not activated on the top site collecti

  
Hi

I installed AKS 2.0 and activated AKS feature. The problem I found was the aks master pages do not get applied if the feature is not activated on the top site collection. why is so?

example: If i activate the feature on http://<servername>/sites/<sitename> and apply the master page, I dont see any changes.

              But if i activate the same aks feature on http://<servername/ then everything started working on all sites.

              The reason i found is the CSS reference in the aks master pages.

              It reference should be given as follows:

                 for http://<servername>/sites/<sitename> ->  <link rel="stylesheet" type="text/css" href="../../Style%20Library/AKS/Aks_Band_Blueband.css"/>

                 for http://<servername>/ -><link rel="stylesheet" type="text/css" href="/Style%20Library/AKS/Aks_Band_Blueband.css"/>

So my question is, am i missing anything? am i supposed to activate the AKS feature on top level site collection at any cost? if yes, why is so? 

And after applying aks master pages, i see differnece in font sizes. Why the font size is getting changed?

Also

Why feature with event receiver doesn't activate properly after site provisioning?

  

Hi!

I have defined feature with event receivers for my document library and for users List .

I try to activate my feature in onet.xml in section <WebFeatures>. After provisioning a new site from onet.xml  all work fine and my feature is shown as activated, but event receivers doesn't fire. It fires only after reactivating my feature (deactivate, then activate it again). But I need my feature works immediately after site provisioning without deactivating and activating it again. Who knows how to solve this problem?

part of ONET.xml

 

      <WebFeatures>

        <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"/>

        <!-- TeamCollab Feature -->

        <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"/>

        <!-- MobilityRedirect -->

        <!--My EventReceivers Feature-->

        <Feature ID ="41178843-A6A4-47c7-9EF9-B8A432E02B88"></Feature>

      </WebFeatures>

 


Feature.xml

<

How to debug feature activation by PowerShell

  
Hello, I got a bunch of wsp files with double the number features from my visual studio 2010 solution. So now I'm using PowerShell to add and install the wsp files to my server and to activate the features for the target site. In Visual Studio 2010 rightlicking and hitting "deploy" works perfectly fine while the PowerShellscript fails with a NullReferenceException. Is there a way to locate the error? I've tried to debug the PowerShell process but when VS2010 opens up to debug the process I get an empty window without any code. I'm using a Windows Server 2008 R2, SharePoint 2010 RTM and Visual Studio 2010 RTM.

Feature activation isssue

  
Hi , I have installed the feature by STSADM command installfeature, then i goes to the site action ->site setting-> site feature i can not able to see the installed feature, so i activated it by stsadm command Activatefeature still i could not able to see the activated feature Can any one help me out to resolve this issue Regards, Pankaj Pawar    

feature stapling done against site definition breaks when saving site as a template?

  
Hi, we have a bunch of feature stapling done against some of our site definitions on a solution we are working on. This feature staple has a bunch of feature dependancies which all work in a variety of ways. One of these dependancies then uses a feature receiver class to do some post provisioning setting up of web part connections and the like. This all works very well when creating a new site from a site definition etc etc. The problem arises when a user opts to provision a site in this way, and then uses the 'save as template' function within sharepoint. (BTW this is WSS 3.0 / MOSS). The site template saves correctly, but now the feature receiver never runs. I'm assuming this is because the associated feature staple doesnt run either? I've looked around and seen some reference to feature stapling not working against templates. Is this true? 

Retract custom master page feature and all site pages stop working

  
There is a requirement to apply custom branding on personal sites in a SP 2010 project. For this I have created a feature which uploads and applies the custom master page on creation of any new personal sites.   I have stapled this feature (using feature stapling concept) to the “SPSPERS” (personal site) site definition. The custom master page is displayed on the creation of new personal sites. On feature deactivation, I am looping through all the personal sites (as the feature is deployed on a team site) and pointing the master URL back to v4.master. But when I retract the solution and browse to the personal site, I am getting a “404 File not found” error.  But am able to view the settings page by typing the URL.   I activated the publishing features and looked at the master page applied to the personal site. It was pointing to v4.master.   Any help on this is appreciated. Regards, Neha

Retract custom master page feature and all site pages stop working

  
I have stapled this feature (using feature stapling concept) to the “SPSPERS” (personal site) site definition. The custom master page is displayed on the creation of new personal sites. On feature deactivation, I am looping through all the personal sites (as the feature is deployed on the root site) and pointing the master URL back to v4.master. But when I retract the solution and browse to the personal site, I am getting a “404 File not found” error.  But am able to view the settings page by typing the URL.   I activated the publishing features and looked at the master page applied to the personal site. It was pointing to v4.master. Any help on this is appreciated. Regards, Neha    

Office Sharepoint Server Publishing Infrastructure is missing in site collection feature SharePoint

  
I was trying to activate the Office Sharepoint Server Publishing Infrastructure feature in the site collection features but the feature is simply not there. Is this option not available in SharePoint Foundation 2010?

content Type at site collection level using feature.

  
I m planning to create a feature to install the content type and site colomun at site collection level. Now my doubt is? 1. what will happen when i de activate a feature with documents already there? 2. what will happen when i de activate a feature without documents? What are points i need to take care? 

Running code after site definition site creation in a event receiver or feature receiver

  
Hi guys I've got a site definition which is pretty much based on STS.This is it's own sharepoint project. Let's call this project SiteDefProj. Next in another SharePoint project (same solution though). Let's call this CustomListProject. In this project I've got a feature which provisions a bunch of lists based on custom content types - this feature is a site scoped. Let's call this feature: CustomListInstances. I have added a feature receiver to this feature to execute some custom code on the lists themselves (under feature activated) In my ONET.XML (part of the SiteDefProj) I have CustomListInstances feature ID as part of my <sitefeatures>. When I do a create site I can actually step through the code and see it actually being executed but after the site is created the list instances are created but it's like the code never run or did anything. The weird part is that stepping through the code while creating a site collection using my SiteDefProj the code runs great with no errors. All lists are there and the code runs smooth. If I manually create a STS site and activate my feature everything works and the code does actually run and the effects are visible after the feature is created. Again I can actually step through it in debug. My suspicion is that there's some sort of a race condition in the CREATE SITE functionality where maybe the web or site collection hol

SharePoint how does it know to use a feature default.aspx deployed instead of site definition defaul

  
I have created a feature which deploys a custom default.aspx page. The deployed file goes to the template\features{featureName} directory. How does SharePoint know to use this default.aspx page instead of the one that is located in SiteTemplates{Site Def name} directory?dave

Error on activation of feature

  
hello everybody i am creating list templates using features . i have created 3 files :- feature.xml , timesheet.xml,schema.xml . the feature is installed succesfully through stsadm but on activating feature error comes in stsadm as "Cannot complete this action.Please try again." I then tried to do it through GUI ->Sitefeatures->activate but error comes . then i tried to use force coomand as following :- stsadm -o activatefeature -name LitwareTimesheets -url "http://a-uhc:100/sites/projectmanagement" -force command prompt shows that operation completed successfully but nothing happens as i can't see feature in site features or list created in my main site . i havepasted files below:- feature.xml <?   xml version="1.0" encoding="utf-8" ?> <   Feature Id="85B2D079-AC3E-4260-9124-DBCAC2ABEAB0"     Title="Litware Timesheets"     Description="This feature provides support for Litware Timesheets"     Version="1.0.0.0"     Hidden="FALSE"     Scope="Site"     DefaultResourceFile="core"     xmlns="http://schemas.microsoft.com/sharepoint/"> <   ElementManifests> <   ElementManifest Location="Timesheets.xml"

Site Collection Reporting Feature?

  
Hi I'm wondering if anyone knows or has seen Microsoft documentation on what activating the "Reporting" feature within the Site Collection Features page will do?  The reason I ask is I thought that activating it at the site collection level was required in order to use site collection usage and site usage reports.  That's what MS's site says here:  http://technet.microsoft.com/en-us/library/cc262541(office.12).aspx  However I have one farm where those usage reports are available, but this site collection feature has not been activated.  Usage logging was enabled through CA for the farm and usage reporting was enabled through CA for the SSP). This is a MOSS 2007 environment.  

Feature with wsp for creating specific groups on any site creation

  
hi, i need to create a sharepoint feature for wss 3.0 with .wsp (wsp for easy deployment) which do folowing funtionality: Ability to run some custom code for creating specific custom groups on every site creation. Feature needs to be activated when deployed so when user create new site it creates groups based on our custom code( i have custom code for creating gorups just need to know how to attached it to feature which works on every site creation event) Any workable example is very helpful for me because i am very confuse and already did reasearch on that. i guess feature stapling is not the solution in my case. Thanks in advanced shaheen

programatically add link in site settings page through feature

  

Hi folks,

          Im newbie in SharePoint, we have created an Application  Page for Managing the WebPart Permissions. We need to add one link called "ManageWebParts"  in the site settings Page so that  the admin can go the site settings and  Navigate to the ManageWebpart.aspx Page using this link. How we can  add the link  through programatically using feature???

 

Your thoughts??

 

 

Thanks & regards

Pulikkan


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend