HtmlDesignerAttribute - Classe

Définit l'attribut HtmlDesigner qui est utilisée sur une propriété personnalisée du composant WebPart. Il spécifie si une propriété personnalisée utilise un générateur personnalisé et l'URL du générateur, ou si la propriété personnalisée n'utilise pas de générateur de n'importe quel, y compris tout générateur par défaut.

Hiérarchie d’héritage

System.Object
  System.Attribute
    Microsoft.SharePoint.WebPartPages.HtmlDesignerAttribute

Espace de noms :  Microsoft.SharePoint.WebPartPages
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Property)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class HtmlDesignerAttribute _
    Inherits Attribute
'Utilisation
Dim instance As HtmlDesignerAttribute
[AttributeUsageAttribute(AttributeTargets.Property)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class HtmlDesignerAttribute : Attribute

Remarques

Ouverture d'un composant WebPart dans Microsoft Visual Studio 2005, la classe HtmlDesignerAttribute est ignorée. Uniquement les générateurs de Visual Studio 2005 par défaut seront utilisés.

Exemples

L'exemple de code suivant illustre un composant WebPart avec une propriété personnalisée qui utilise HtmlDesignerAttribute pour définir un générateur personnalisé statique.

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

namespace WebPartLibrary2
{
    
    [XmlRootAttribute(Namespace="WebPartLibrary2")]

    
    public class HtmlDesignerAttributeTestPart: WebPart
    {
        ///    Member variable for a property with 
        ///    HtmlDesignerAttribute defined for a custom builder
        private string customPropertyValue = "This Web Part has a custom property";
        
        /// <summary>
        ///        Use HtmlDesignerAttribute to define a static custom 
        ///        builder builder.aspx for the custom property.
        /// </summary>
        [WebPartStorage(Storage = Storage.Personal), 
        DefaultValue(""), 
        HtmlDesignerAttribute("http://myserver/builder.aspx")]
        public string CustomProperty
        {
            get
            {
                return customPropertyValue;
            }
            set
            {    
                customPropertyValue = value;
            }
        }
        
        /// <summary>
        ///        Renders the content of the HtmlDesignerAttributeTestPart.
        /// </summary>
        protected override void RenderWebPart (HtmlTextWriter output)
        {
            output.Write(SPEncode.HtmlEncode(CustomProperty));
        }
    }

}
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
Imports System.Xml

Namespace WebPartLibrary2

    <XmlRootAttribute(Namespace:="WebPartLibrary2")> _
    Public Class HtmlDesignerAttributeTestPart
        Inherits WebPart
        '''    Member variable for a property with 
        '''    HtmlDesignerAttribute defined for a custom builder
        Private customPropertyValue As String = "This Web Part has a custom property"

        ''' <summary>
        '''        Use HtmlDesignerAttribute to define a static custom 
        '''        builder builder.aspx for the custom property.
        ''' </summary>
        <WebPartStorage(Storage := Storage.Personal), DefaultValue(""), HtmlDesignerAttribute("http://myserver/builder.aspx")> _
        Public Property CustomProperty() As String
            Get
                Return customPropertyValue
            End Get
            Set(ByVal value As String)
                customPropertyValue = value
            End Set
        End Property

        ''' <summary>
        '''        Renders the content of the HtmlDesignerAttributeTestPart.
        ''' </summary>
        Protected Overrides Sub RenderWebPart(ByVal output As HtmlTextWriter)
            output.Write(SPEncode.HtmlEncode(CustomProperty))
        End Sub
    End Class

End Namespace

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

HtmlDesignerAttribute - Membres

Microsoft.SharePoint.WebPartPages - Espace de noms