SPWeb Class

SPWeb – Represents a SharePoint Foundation Web site. (a web site under a site collection).

(You can use AllWebs property of the SPSite class to return all Web sites within the site collection)

Use the Web property of the SPContext class to return an SPWeb object that represents the current Web site, as follows:
SPWeb oWebsite = SPContext.Current.Web;

This returns the top level site of a site collection!!!

To return the top-level Web site
for the site collection, you can use the Site() property of the SPContext class and the RootWeb property of the SPSite class as follows:
using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)

{


}

To return a specific Web site, you can use the OpenWeb method of the SPSite class as follows.
using(SPWeb oWebsite = SPContext.Current.Site.OpenWeb(“Website_URL”))

{


}

SPWeb.Features — Gets the collection of Features that are currently activated in the Web site.

SPWeb.Properties – Gets a SPPropertyBag object with the metadata for the Web site.


using (SPSite site = new SPSite(http://localhost”))

{


using (SPWeb web = site.OpenWeb())

{

SPPropertyBag props = web.Properties;


foreach (DictionaryEntry de in props)

{

Console.WriteLine(“Key = {0}, Value = {1}”, de.Key, de.Value);

}

}

}

 

SPWeb.Webs — Gets a Web site collection object that represents all Web sites immediately beneath the Web site, excluding children of those Web sites.

SPWebCollection.ADD — Creates a Web site object with the specified Web site-relative URL.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: