PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Web Part for a Microsoft Windows SharePoint Services site named Site1. You install a feature named TimeFeature on Site1.

You write the following code segment.

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

You need to display the current time to the user only if the TimeFeature feature is activated on Site1.

Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Dim feature As SPFeatureDefinition = _
SPFarm.Local.FeatureDefinitions(“TimeFeature”)
If Not (feature Is Nothing) Then
Dim timeLabel As Label = New Label
timeLabel.Text = DateTime.Now.ToShortTimeString
Controls.Add(timeLabel)
End If

B.
For Each feature As SPFeature In web.Features
If feature.Definition.Name = “TimeFeature” Then
Dim timeLabel As Label = New Label
timeLabel.Text = DateTime.Now.ToShortTimeString
Controls.Add(timeLabel)
End If
Next

C.
For Each feature As SPFeature In web.Features
If feature.Definition.ActivateOnDefault = True Then
Dim timeLabel As Label = New Label
timeLabel. Text = DateTime.Now.ToShortTimeString
Controls.Add(timeLabel)
End If
Next

D.
For Each feature As SPFeatureDefinition In web.Features
If Not (feature.Name.Equals(“TimeFeature”)) Then
Dim timeLabel As Label = New Label
timeLabel.Text = DateTime.Now.ToShortTimeString
Controls.Add(timeLabel)
End If
Next


Leave a Reply