WebPartChrome.GetWebPartVerbs Method

Gets a collection of verbs that should be rendered with a WebPart control.

Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in system.web.dll)

protected:
virtual WebPartVerbCollection^ GetWebPartVerbs (
	WebPart^ webPart
)
protected WebPartVerbCollection GetWebPartVerbs (
	WebPart webPart
)
protected function GetWebPartVerbs (
	webPart : WebPart
) : WebPartVerbCollection
Not applicable.

Parameters

webPart

The control currently being rendered.

Return Value

A WebPartVerbCollection containing all the verbs that should be rendered with webPart.

Exception typeCondition

ArgumentNullException

webPart is a null reference (Nothing in Visual Basic).

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.

No code example is currently available or this language may not be supported.

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 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: