WebPartVerb.Description Property (System.Web.UI.WebControls.WebParts)


Gets or sets a short description of the verb.

 virtual property System::String ^ Description  System::String ^ get(); void set(System::String ^ value); ;
public virtual string Description  get; set; 
member this.Description : string with get, set
Public Overridable Property Description As String

Property Value


The following code example shows how to override the Description property in a derived class inheriting from WebPartVerb. This source code shows only the portion of the code for the custom zone and the WebPartVerb class that overrides the property. The rest of the code required to run the example can be found in the Example section of the WebPartVerb class overview.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Security.Permissions;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Samples.AspNet.CS.Controls

This code sample creates a Web Part zone and adds the 
"Copy Web Part" verb to any control in the zone.
    Level = AspNetHostingPermissionLevel.Minimal)]
    Level = AspNetHostingPermissionLevel.Minimal)]
public class ZoneWithAddedVerb : WebPartZone

  protected override void OnCreateVerbs(WebPartVerbsEventArgs e)
    List<WebPartVerb> newVerbs = new List<WebPartVerb>();
    newVerbs.Add(new CopyWebPartVerb(CopyWebPartToNewOne));
    e.Verbs = new WebPartVerbCollection(e.Verbs,newVerbs);

  void CopyWebPartToNewOne(object sender, WebPartEventArgs e)
    WebPartManager wpmgr = 
    System.Web.UI.WebControls.WebParts.WebPart wp;
    Type tp = e.WebPart.GetType(); 
    wp = (System.Web.UI.WebControls.WebParts.WebPart)Activator.CreateInstance(tp);   
    wpmgr.AddWebPart(wp, e.WebPart.Zone, e.WebPart.ZoneIndex + 1);

    Level = AspNetHostingPermissionLevel.Minimal)]
    Level = AspNetHostingPermissionLevel.Minimal)]
  internal class CopyWebPartVerb : WebPartVerb
    private const String _copyWebPartImageUrl = "~/CopyVerb.ico";

    internal CopyWebPartVerb(WebPartEventHandler serverClickHandler) :  
       base("MyVerb", serverClickHandler)
    public override string Text
      get  return "Copy Web Part"; 
      set  ;
    public override string Description
      get  return "This verb will copy this web part control " +
        "to a new one below"; 
      set  ; 
    public override bool Enabled
      get  return base.Enabled; 
      set  base.Enabled = value; 
    public override string ImageUrl
      get  return _copyWebPartImageUrl; 
      set  ; 

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Security.Permissions
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

' This code sample creates a Web Part zone and adds the 
' "Copy Web Part" verb to any control in the zone.
Namespace Samples.AspNet.VB.Controls

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class ZoneWithAddedVerb
    Inherits WebPartZone

    'public class ExtendedWebPartZoneBase 
    Protected Overrides Sub OnCreateVerbs(ByVal e _
      As WebPartVerbsEventArgs)

      Dim newVerbs As List(Of WebPartVerb) = _
        New List(Of WebPartVerb)
      newVerbs.Add(New CopyWebPartVerb(AddressOf CopyWebPartToNewOne))
      e.Verbs = New WebPartVerbCollection(e.Verbs, newVerbs)

    End Sub 'OnCreateVerbs

    Sub CopyWebPartToNewOne(ByVal sender As Object, _
      ByVal e As WebPartEventArgs)

      Dim wpmgr As WebPartManager = _
      Dim wp As System.Web.UI.WebControls.WebParts.WebPart
      Dim tp As Type = e.WebPart.GetType()
      wp = CType(Activator.CreateInstance(tp), _
      wpmgr.AddWebPart(wp, e.WebPart.Zone, e.WebPart.ZoneIndex + 1)

    End Sub

  End Class

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Friend Class CopyWebPartVerb
    Inherits WebPartVerb
    Private Const _copyWebPartImageUrl As String = "~/CopyVerb.ico"

    Friend Sub New(ByVal serverClickHandler As WebPartEventHandler)
      MyBase.New("MyVerb", serverClickHandler)

    End Sub 'New

    Public Overrides Property [Text]() As String
        Return "Copy Web Part"
      End Get
      Set(ByVal value As String)
      End Set
    End Property

    Public Overrides Property Description() As String
        Return "This verb will copy this web part control to a " _
               & "new one below"
      End Get
      Set(ByVal value As String)
      End Set
    End Property

    Public Overrides Property Enabled() As Boolean
        Return MyBase.Enabled
      End Get
      Set(ByVal value As Boolean)
        MyBase.Enabled = value
      End Set
    End Property
    Public Overrides Property ImageUrl() As String
        Return Me._copyWebPartImageUrl
      End Get
      Set(ByVal value As String)
      End Set
    End Property

  End Class

End Namespace


Use this property to get or set a description of a verb that appears as a ToolTip when a user positions a mouse pointer over the verb.

Applies to