Which code segment should you use?

You create a Web Part and deploy the Web Part to a Windows SharePoint Services site named Site1. You create a feature named MyFeature.

You write the following code segment.

Private site As SPSite = New SPSite(“http://server/site1”) _
Private web As SPWeb = site.OpenWeb()

You need to activate the feature only on Site1 when the Web Part is loaded.

Which code segment should you use?

You create a Web Part and deploy the Web Part to a Windows SharePoint Services site named Site1. You create a feature named MyFeature.

You write the following code segment.

Private site As SPSite = New SPSite(“http://server/site1”) _
Private web As SPWeb = site.OpenWeb()

You need to activate the feature only on Site1 when the Web Part is loaded.

Which code segment should you use?

A.
Dim feature As SPFeatureDefinition = _
SPFarm.Local.FeatureDefinitions(“MyFeature”) _
web.Features.Add(feature.Id)

B.
Dim feature As SPFeatureDefinition = _
SPFarm.Local.FeatureDefinitions(“MyFeature”) _
site.Features.Add(feature.Id)

C.
Dim feature As SPFeatureDefinition = _
SPFarm.Local.FeatureDefinitions(“MyFeature”) _
site.WebApplication.WebService.Features.Add(feature.Id)

D.
Dim MyFeature As SP FeatureDefinition = New SPFeatureDefinition() _
site.WebApplication.WebService.Features.Add(MyFeature.Id)



Leave a Reply 0

Your email address will not be published. Required fields are marked *