UrlPropertyAttribute Classe

Definição

Define o atributo que controla o uso para identificar as propriedades de cadeia de caracteres que contém os valores da URL. Essa classe não pode ser herdada.

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
Herança
UrlPropertyAttribute
Atributos

Exemplos

O exemplo de código a seguir demonstra uma classe que implementa uma propriedade específica de URL. Neste exemplo de código, um UrlPropertyAttribute atributo é aplicado à TargetUrl propriedade da CustomHyperLinkControl classe. O atributo define um filtro de arquivo específico para arquivos 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

Comentários

O UrlPropertyAttribute atributo é um atributo aplicado a uma propriedade de controle que representa uma URL. Além de marcar uma propriedade de cadeia de caracteres como representando uma URL, o UrlPropertyAttribute atributo define a Filter propriedade que identifica tipos de arquivo específicos que podem ser usados para filtrar a propriedade.

Construtores

UrlPropertyAttribute()

Inicializa uma nova instância padrão da classe UrlPropertyAttribute.

UrlPropertyAttribute(String)

Inicializa uma nova instância da classe UrlPropertyAttribute, definindo a propriedade Filter para a cadeia de caracteres especificada.

Propriedades

Filter

Obtém um filtro de arquivo associado à propriedade específica da URL.

TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.

(Herdado de Attribute)

Métodos

Equals(Object)

Retorna um valor que indica se essa instância é igual a um objeto especificado.

GetHashCode()

Retorna o código hash para a instância.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.

(Herdado de Attribute)

Aplica-se a