- Represents the context of an HTTP request in Microsoft
SharePoint Foundation.
- This class also available in SharePoint Sandboxed
solution also.
- Present in the Assembly Microsoft.SharePoint.dll.
- This class
returns current information about list, site and also site collection,
also you can retrieve current user name also.
- Here are
some example of SPContext class
string
userLoginName=SPContext.Current.Web.CurrentUser.LoginName; //This will
return current login name.
SPList currentList = SPContext.Current.List; //Give
you the current list associated with the context
SPWeb
currentWeb = SPContext.Current.Web; //Returns the current site
associated with the context
SPSite currentSite = SPContext.Current.Site; //Returns
current site collection associated with the context
SPWebApplication currentWebApplication =
SPContext.Current.Site.WebApplication; //Returns current web application
associated with the context.
SPContext.Current.SiteFeatures
//Give you the activated site collection features of the SharePoint
context.
You can check more on msdn in this URL: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.aspx
No comments:
Post a Comment
Note: only a member of this blog may post a comment.