I’m working on a WebPart, to be used in SharePoint, that will display a listing of documents within a document library. To do so, I believe I need to reference the SPWeb object for which the web part is hosted on. Unfortunately, I don’t see how to access the current SPSite or SPWeb from within a WebPart. How would I access these from within a WebPart?
Share
Use the static
SPContext.Currentproperty to get access to your SharePoint environment. FromSPContextyou can get access to both the currentSPWebandSPSite.