Compartilhar via


SPWebEventReceiver.WebAdding Method

Synchronous Before event that occurs before a new subsite is created, but not when the root web site of a new site collection is created.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Overridable Sub WebAdding ( _
    properties As SPWebEventProperties _
)
'Usage
Dim instance As SPWebEventReceiver
Dim properties As SPWebEventProperties

instance.WebAdding(properties)
public virtual void WebAdding(
    SPWebEventProperties properties
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

properties is null .

Remarks

The WebAdding(SPWebEventProperties) event occurs on the parent Web that is creating the new subweb, since the new subweb does not yet exist. For this reason, the URL-related properties may appear to be null, when in fact these values should be the URL of the parent Web when the parent Web is the root Web. More specifically, the ServerRelativeUrl property in the WebAdding event is the parent Web. On the other hand, this property on the WebProvisioned(SPWebEventProperties) event should be the newly created subweb.

Notes to Implementers

Since an event receiver has to be registered with the site collection before it's handlers can execute, the WebAdding and WebProvisioned handlers cannot run when a site collection and its root web site are created.

See Also

Reference

SPWebEventReceiver Class

SPWebEventReceiver Members

Microsoft.SharePoint Namespace