UrlPropertyAttribute Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Definisce l'attributo usato dai controlli per identificare le proprietà stringa contenenti valori URL. Questa 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à
- 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 di file specifico per ASP.NET file.
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à del 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 in base alla proprietà .
Costruttori
| Nome | Descrizione |
|---|---|
| UrlPropertyAttribute() |
Inizializza una nuova istanza predefinita della UrlPropertyAttribute classe . |
| UrlPropertyAttribute(String) |
Inizializza una nuova istanza della UrlPropertyAttribute classe impostando la Filter proprietà sulla stringa specificata. |
Proprietà
| Nome | Descrizione |
|---|---|
| Filter |
Ottiene un filtro di file associato alla proprietà specifica dell'URL. |
| TypeId |
Se implementato in una classe derivata, ottiene un identificatore univoco per questo Attribute. (Ereditato da Attribute) |
Metodi
| Nome | Descrizione |
|---|---|
| Equals(Object) |
Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato. |
| GetHashCode() |
Restituisce il codice hash per questa istanza. |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| IsDefaultAttribute() |
Quando sottoposto a 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 è uguale a un oggetto specificato. (Ereditato da Attribute) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
Implementazioni dell'interfaccia esplicita
| Nome | Descrizione |
|---|---|
| _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 per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per 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 alle proprietà e ai metodi esposti da un oggetto . (Ereditato da Attribute) |