SPWebCollection.Add method (String)
使用指定的網站與相對 URL 建立SPWeb物件。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Function Add ( _
strWebUrl As String _
) As SPWeb
'用途
Dim instance As SPWebCollection
Dim strWebUrl As String
Dim returnValue As SPWeb
returnValue = instance.Add(strWebUrl)
public SPWeb Add(
string strWebUrl
)
參數
strWebUrl
Type: System.String字串,指定新網站的 URL。如果SPWebCollection物件代表在網站集合內的網站,是伺服器相對 URL,並開頭為正斜線 (例如,"/ 網站/MySitecollection/MyNewWebSite")。如果 SPWebCollection 物件代表直接在網站的子網站,URL 是相對於網站,並不是以正斜線 (例如,"MyNewWebSite") 開頭。
傳回值
Type: Microsoft.SharePoint.SPWeb
代表網站的SPWeb物件。
Examples
下列程式碼範例會建立目前的網站集合內的網站。
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim subSites As SPWebCollection = siteCollection.AllWebs
Dim mySite As SPWeb = subSites.Add("MyNewWebsite")
mySite.Dispose()
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
SPWeb oWebsite = collWebsites.Add("Website/Subsite/MyNewSubsite");
oWebsite.Dispose();
注意事項 |
---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |