Microsoft
70-573 · Question #202
You are creating a new Web Part. You need to create a reference to the current subsite without having to dispose of any returned objects. Which code segment should you use? Dim site As…
The correct answer is D. Dim site As SPWeb = SPContext.Current.Web. See the full explanation below for the reasoning.
Question
You are creating a new Web Part. You need to create a reference to the current subsite without having to dispose of any returned objects. Which code segment should you use? Dim site As SPWebCollection = siteCollection.AllWebs Dim site As SPWeb = siteCollection.RootWeb
Options
- CDim site As SPSite = SPContext.Current.Site
- DDim site As SPWeb = SPContext.Current.Web
How the community answered
(29 responses)- C21% (6)
- D79% (23)
Community Discussion
No community discussion yet for this question.