Microsoft
70-573 · Question #198
You create a Web Part. You need to display the number of visits to a SharePoint site collection in a label named LblVisits. You write the following code segment. (Line numbers are included for…
The correct answer is A. Dim esite As New SPSite(SPContext.Current.Site.ID). See the full explanation below for the reasoning.
Question
You create a Web Part. You need to display the number of visits to a SharePoint site collection in a label named LblVisits. You write the following code segment. (Line numbers are included for reference only.) 01 RunWithElevatedPrivileges(ElevateSub) 02 Private Sub ElevatedSub() 03 Try 04 05 LblVisits.Text = site.Usage.Visits.ToString() 06 Finally 07 ... 08 End Try 09 End Sub Which code segment should you add at line 04?
Options
- ADim esite As New SPSite(SPContext.Current.Site.ID)
- BDim esite As SPSite = SPContext.Current.Site
- CDim esite As SPSite = SPContext.GetContext(HttpContext.Current).Site
- DDim esite As SPSite = SPControl.GetContextSite(HttpContext.Current)
How the community answered
(42 responses)- A81% (34)
- B5% (2)
- C2% (1)
- D12% (5)
Community Discussion
No community discussion yet for this question.