Partager via


UrlPropertyAttribute Classe

Définition

Définit l’attribut que les contrôles utilisent pour identifier les propriétés de chaîne contenant des valeurs d’URL. Cette classe ne peut pas être héritée.

public ref class UrlPropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class UrlPropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type UrlPropertyAttribute = class
    inherit Attribute
Public NotInheritable Class UrlPropertyAttribute
Inherits Attribute
Héritage
UrlPropertyAttribute
Attributs

Exemples

L’exemple de code suivant illustre une classe qui implémente une propriété spécifique à l’URL. Dans cet exemple de code, un UrlPropertyAttribute attribut est appliqué à la TargetUrl propriété de la CustomHyperLinkControl classe. L’attribut définit un filtre de fichier spécifique pour les fichiers ASP.NET.

public class CustomHyperLinkControl : WebControl
{
    public CustomHyperLinkControl() { }

    // The TargetUrl property represents the URL that 
    // the custom hyperlink control navigates to.
    [UrlProperty("*.aspx")]
    public string TargetUrl
    {
        get
        {
            string s = (string)ViewState["TargetUrl"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["TargetUrl"] = value;
        }
    }

    // The Text property represents the visible text that 
    // the custom hyperlink control is displayed with.        
    public virtual string Text
    {
        get
        {
            string s = (string)ViewState["Text"];
            return ((s == null) ? String.Empty : s);
        }
        set
        {
            ViewState["Text"] = value;
        }
    }

    // Implement method to render the control.
}
Public Class CustomHyperLinkControl
    Inherits WebControl

    Public Sub New()
    End Sub

    ' The TargetUrl property represents the URL that 
    ' the custom hyperlink control navigates to.        
    <UrlProperty("*.aspx")> _
    Public Property TargetUrl() As String
        Get
            Dim s As String = CStr(ViewState("TargetUrl"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("TargetUrl") = value
        End Set
    End Property

    ' The Text property represents the visible text that 
    ' the custom hyperlink control is displayed with.                
    Public Overridable Property [Text]() As String
        Get
            Dim s As String = CStr(ViewState("Text"))
            If (s Is Nothing) Then
                Return String.Empty
            Else
                Return s
            End If
        End Get
        Set(ByVal value As String)
            ViewState("Text") = value
        End Set
    End Property

    ' Implement method to render the control.

End Class

Remarques

L’attribut UrlPropertyAttribute est un attribut appliqué à une propriété de contrôle qui représente une URL. Outre le marquage d’une propriété de chaîne comme représentant une URL, l’attribut UrlPropertyAttribute définit la Filter propriété qui identifie des types de fichiers spécifiques qui peuvent être utilisés pour filtrer sur la propriété.

Constructeurs

Nom Description
UrlPropertyAttribute()

Initialise une nouvelle instance par défaut de la UrlPropertyAttribute classe.

UrlPropertyAttribute(String)

Initialise une nouvelle instance de la UrlPropertyAttribute classe, en définissant la Filter propriété sur la chaîne spécifiée.

Propriétés

Nom Description
Filter

Obtient un filtre de fichier associé à la propriété spécifique à l’URL.

TypeId

En cas d’implémentation dans une classe dérivée, obtient un identificateur unique pour cette Attribute.

(Hérité de Attribute)

Méthodes

Nom Description
Equals(Object)

Retourne une valeur qui indique si cette instance est égale à un objet spécifié.

GetHashCode()

Retourne le code de hachage pour cette instance.

GetType()

Obtient la Type de l’instance actuelle.

(Hérité de Object)
IsDefaultAttribute()

En cas de substitution dans une classe dérivée, indique si la valeur de cette instance est la valeur par défaut de la classe dérivée.

(Hérité de Attribute)
Match(Object)

En cas de substitution dans une classe dérivée, retourne une valeur qui indique si cette instance est égale à un objet spécifié.

(Hérité de Attribute)
MemberwiseClone()

Crée une copie superficielle du Objectactuel.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l’objet actuel.

(Hérité de Object)

Implémentations d’interfaces explicites

Nom Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mappe un jeu de noms avec un jeu correspondant d'identificateurs de dispatch.

(Hérité de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Récupère les informations de type d’un objet, qui peuvent être utilisées pour obtenir les informations de type d’une interface.

(Hérité de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Récupère le nombre d'interfaces d'informations de type fourni par un objet (0 ou 1).

(Hérité de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fournit l’accès aux propriétés et méthodes exposées par un objet.

(Hérité de Attribute)

S’applique à