UrlPropertyAttribute Classe

Definizione

Definisce l'attributo utilizzato dai controlli per identificare proprietà stringa contenenti valori URL. La classe non può essere ereditata.

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
Ereditarietà
UrlPropertyAttribute
Attributi

Esempio

Nell'esempio di codice seguente viene illustrata una classe che implementa una proprietà specifica dell'URL. In questo esempio di codice viene applicato un UrlPropertyAttribute attributo alla TargetUrl proprietà della CustomHyperLinkControl classe. L'attributo imposta un filtro file specifico per i file di 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

Commenti

L'attributo UrlPropertyAttribute è un attributo applicato a una proprietà di controllo che rappresenta un URL. Oltre a contrassegnare una proprietà stringa come che rappresenta un URL, l'attributo UrlPropertyAttribute definisce la Filter proprietà che identifica tipi di file specifici che possono essere usati per filtrare sulla proprietà.

Costruttori

UrlPropertyAttribute()

Inizializza una nuova istanza predefinita della classe UrlPropertyAttribute.

UrlPropertyAttribute(String)

Inizializza una nuova istanza della classe UrlPropertyAttribute, impostando la proprietà Filter sulla stringa specificata.

Proprietà

Filter

Ottiene un filtro di file associato alla proprietà specifica dell'URL.

TypeId

Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.

(Ereditato da Attribute)

Metodi

Equals(Object)

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

GetHashCode()

Restituisce il codice hash per l'istanza.

GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

In caso di override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.

(Ereditato da Attribute)
Match(Object)

Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

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

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da Attribute)

Si applica a