WebPartChrome::GetWebPartVerbs Method
Gets a collection of verbs that should be rendered with a WebPart control.
Assembly: System.Web (in System.Web.dll)
Parameters
- webPart
- Type: System.Web.UI.WebControls.WebParts::WebPart
The control currently being rendered.
Return Value
Type: System.Web.UI.WebControls.WebParts::WebPartVerbCollectionA WebPartVerbCollection containing all the verbs that should be rendered with webPart.
| Exception | Condition |
|---|---|
| ArgumentNullException | webPart is nullptr. |
The GetWebPartVerbs method provides developers with an opportunity to override the method and exclude certain verbs from being rendered. This is similar to the FilterWebPartVerbs method, which also can exclude verbs from being rendered.
However, the GetWebPartVerbs method is not meant for cases where you want to check some criteria to decide whether to render a verb. Instead, this method is useful when you know in advance that you always want to exclude a certain verb. For example, if you develop a custom WebPartChrome class, you might decide that you always want to exclude the close verb on WebPart controls, so that users can never close the controls. Rather than setting the AllowClose property to false on all the controls, you can simply override the GetWebPartVerbs method and exclude close verbs from being rendered on any WebPart control rendered with your custom WebPartChrome object.
The following code example demonstrates use of the GetWebPartVerbs method. For the full code required to run the example, see the Example section of the WebPartChrome class overview topic.
The following section from the code example demonstrates how to override the GetWebPartVerbs method. The overridden method uses the base method to retrieve all verbs from the webPart control, then iterates through the verb collection, adding all verbs except the close verb to an ArrayList object. This reduced set of verbs is then assigned to a new WebPartVerbCollection, which is returned to the caller.
If you load the Web page in a browser and click the verbs menu (shown with a downward arrow in the title bar) of each WebPart control, you can see that the close verb is not rendered for any control.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.