Tag Info

New answers tagged


Your code is wrong, it's using the same variable name twice. It should be: SPEventReceiverDefinition grpUserAdded = site.EventReceivers.Add(); grpUserAdded.Name = "Event Receiver Group User Added"; grpUserAdded.Type = SPEventReceiverType.GroupUserAdding; grpUserAdded.Assembly = "BI.Lofbergs.Intranet.Business, Version=, ...


The problem you would have is timing, the field must have been created before you provision your content type. So the FeatureActivated is a no go. I would not go for FeatureInstalling either since you can not control with ease the execution order. I sometimes uses the FeatureActivated event, but in those cases I create both content type, fields, and binds ...


The visual web part should be included to the Site-scoped feature, as a result properties.Feature.Parent is a SPSite object. You need to check feature scope and use the code below if the scope is site. SPSite site = properties.Feature.Parent as SPSite; if (site != null){ SPWeb web = site.RootWeb; SPList laptopList = web.Lists["Laptops"]; ... }


web.lists[] will cause an exception if the list is not there. use TryGetList instead

Top 50 recent answers are included