UrlPropertyAttribute Konstruktory
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Inicializuje novou instanci UrlPropertyAttribute třídy.
Přetížení
| Name | Description |
|---|---|
| UrlPropertyAttribute() |
Inicializuje novou výchozí instanci UrlPropertyAttribute třídy. |
| UrlPropertyAttribute(String) |
Inicializuje novou instanci UrlPropertyAttribute třídy a nastaví Filter vlastnost na zadaný řetězec. |
UrlPropertyAttribute()
Inicializuje novou výchozí instanci UrlPropertyAttribute třídy.
public:
UrlPropertyAttribute();
public UrlPropertyAttribute();
Public Sub New ()
Příklady
Následující příklad kódu ukazuje třídu, která implementuje vlastnost specifickou pro adresu URL. V tomto příkladu kódu se na vlastnost CustomHyperLinkControl třídy použije TargetUrl výchozí UrlPropertyAttribute atribut. Atribut označuje podporu pro všechny typy adres URL a určuje výchozí filtr souborů nastavený na "*.*".
public class CustomHyperLinkControl : WebControl
{
public CustomHyperLinkControl() { }
// The TargetUrl property represents the URL that
// the custom hyperlink control navigates to.
[UrlProperty()]
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 this 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()> _
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
Poznámky
Výchozí instance UrlPropertyAttribute třídy je inicializována vlastností Filter nastavenou na hodnotu "*.*".
Platí pro
UrlPropertyAttribute(String)
Inicializuje novou instanci UrlPropertyAttribute třídy a nastaví Filter vlastnost na zadaný řetězec.
public:
UrlPropertyAttribute(System::String ^ filter);
public UrlPropertyAttribute(string filter);
new System.Web.UI.UrlPropertyAttribute : string -> System.Web.UI.UrlPropertyAttribute
Public Sub New (filter As String)
Parametry
- filter
- String
Filtr souborů přidružený k vlastnosti specifické pro adresu URL.
Příklady
Následující příklad kódu ukazuje třídu, která implementuje vlastnost specifickou pro adresu URL. V tomto příkladu UrlPropertyAttribute kódu je atribut použit na TargetUrl vlastnost CustomHyperLinkControl třídy. Atribut nastaví určitý filtr souborů pro ASP.NET soubory.
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
Poznámky
Instance UrlPropertyAttribute třídy vytvořené pomocí tohoto konstruktoru je inicializována vlastností nastavenou Filter na filter.