Diff B/w SPSite & SPWeb

SPSite class:

  • SPSite Represents a collection of sites on a virtual server, including a top-level site and all its subsites.
  • Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections on the virtual server.
  • SPSite.OpenWeb Method: Returns the site that is located
    at the specified server-relative or site-relative URL.

SPWeb class :
SPWeb Simply represents Windows SharePoint Services Web site.

Code sample to create a site:

SPSite mySite = new SPSite("http://servername/");
SPWeb myWeb = mySite.AllWebs["Site_Name"];
SPWeb myRootWeb = mySite.RootWeb;

Note:

  • SPSite and SPWeb inherit directly from System.Object
  • Calling Dispose ensures all resources used by those objects are immediately released.

Comments

Popular posts from this blog

How to Add onLoad JavaScript event in SharePoint?

How to add to Sub-Sub Menu in SharePoint

Adding Validation to a Custom NewForm.aspx in SharePoint & Redirect