Interfaz IAddtoGallery

Define una propiedad que permite a un elemento Web Agregar elementos de menú en el panel de herramientas de la Galería de Agregar elementos Web.

Espacio de nombres:  Microsoft.SharePoint.WebPartPages
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Interface IAddtoGallery
'Uso
Dim instance As IAddtoGallery
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IAddtoGallery

Ejemplos

En el ejemplo de código siguiente se muestra una clase de elemento Web que implementa la interfaz IAddtoGallery y establece la propiedad GalleryOptions para definir dos comandos de menú que amplían el menú del panel de herramientas Agregar elementos Web. Para obtener información sobre el formato de la utilización de fragmento XML para definir los comandos de menú, vea la propiedad GalleryOptions .

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;

namespace ExampleWebPartLibrary
{

    [DefaultProperty("Text"),
        ToolboxData("<{0}:IAddToGalleryWebPart 
            runat=server></{0}:IAddToGalleryWebPart>"),
        XmlRoot(Namespace="ExampleWebPartLibrary")]

    // Derive from WebPart base class and implement the IAddToGallery interface.
    public class IAddToGalleryWebPart : 
    Microsoft.SharePoint.WebPartPages.WebPart, 
        Microsoft.SharePoint.WebPartPages.IAddtoGallery
    {
        
        // Create and return the XML fragment to define two menu commands.
        Public string GalleryOptions
        {
            get
            {
                string mytemplate;
                mytemplate = "";
                mytemplate += "<?xml version=\"1.0\"?>";
                mytemplate += "<GalleryOptions>";
                mytemplate += "<Option ID=\"{CAEAE2BB-56F8-426f-A279-
                    84E2465808B7}\">";
                mytemplate += "<OptionName>Command 1</OptionName>";
                mytemplate += "<LinkValue>javascript:alert('Command 1 
                    was clicked.');</LinkValue>";
                mytemplate += "</Option>";
                mytemplate += "<Option ID=\"{3A570BED-D135-4220-8460-
                    7FE34B88CB8D}\">";
                mytemplate += "<OptionName>Command 2</OptionName>";
                mytemplate += "<LinkValue>javascript:alert('Command 2 
                    was clicked.');</LinkValue>";
                mytemplate += "</Option>";
                mytemplate += "</GalleryOptions>";
                return mytemplate;
           }
        }

        /// <summary>
        /// Render this Web Part to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            // Code for rendering Web Part.
        }
    }
}
Imports System
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebPartPages

Namespace ExampleWebPartLibrary

    ' Derive from WebPart base class and implement the IAddToGallery interface.
    <DefaultProperty("Text"), ToolboxData("<{0}:IAddToGalleryWebPart runat=server></{0}:IAddToGalleryWebPart>"), XmlRoot(Namespace:="ExampleWebPartLibrary")> _
    Public Class IAddToGalleryWebPart
        Inherits Microsoft.SharePoint.WebPartPages.WebPart
        Implements Microsoft.SharePoint.WebPartPages.IAddtoGallery

        ' Create and return the XML fragment to define two menu commands.
        Private Public ReadOnly Property GalleryOptions() As String
            Get
                Dim mytemplate As String
                mytemplate = ""
                mytemplate &= "<?xml version=""1.0""?>"
                mytemplate &= "<GalleryOptions>"
                mytemplate &= "<Option ID=""{CAEAE2BB-56F8-426f-A279- 84E2465808B7}\">"; mytemplate += ".Chars(Of OptionName)Command 1</OptionName>"; mytemplate += ".Chars(Of LinkValue)javascript:alert( 'Command 1 was clicked.');
                </LinkValue>"; mytemplate += "</Option>"; mytemplate += "<Option ID=""
                    3A570BED-D135-4220-8460- 7FE34B88CB8D
                \">"
                mytemplate &= "<OptionName>Command 2</OptionName>"
                mytemplate &= "<LinkValue>javascript:alert('Command 2 was clicked.');</LinkValue>"
                mytemplate &= "</Option>"
                mytemplate &= "</GalleryOptions>"
                Return mytemplate
            End Get
        End Property

        ''' <summary>
        ''' Render this Web Part to the output parameter specified.
        ''' </summary>
        ''' <param name="output"> The HTML writer to write out to </param>
        Protected Overrides Sub RenderWebPart(ByVal output As HtmlTextWriter)
            ' Code for rendering Web Part.
        End Sub
    End Class
End Namespace

Vea también

Referencia

Miembros IAddtoGallery

Espacio de nombres Microsoft.SharePoint.WebPartPages