Saturday, July 3, 2010

SPContext. What Is It?

1.  Its a SharePoint Class.
2.  It represents the context in an HTTP request.

3.  We use SPContext to return context (background / situation / perspective)information about such objects as:


- Current Web App
- Current Site Collection
- Current Site
- Current List
- Current List Item

e.g:

-  SPWebApplication WebAppCur = SPContext.Current.WebApplication;
-  SPSite SiteCollCur = SPContext.Current.Site;
-  SPWeb WebCur = SPContext.Current.Web;
-  SPList ListCur = SPContext.Current.List;

Note:  Site represents SiteCollection and Web represents Site in SharePoint 2007.

No comments: