UrlPropertyAttribute Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de UrlPropertyAttribute klasse.
Overloads
| Name | Description |
|---|---|
| UrlPropertyAttribute() |
Initialiseert een nieuw standaardexemplaren van de UrlPropertyAttribute klasse. |
| UrlPropertyAttribute(String) |
Initialiseert een nieuw exemplaar van de UrlPropertyAttribute klasse, waarbij de Filter eigenschap wordt ingesteld op de opgegeven tekenreeks. |
UrlPropertyAttribute()
Initialiseert een nieuw standaardexemplaren van de UrlPropertyAttribute klasse.
public:
UrlPropertyAttribute();
public UrlPropertyAttribute();
Public Sub New ()
Voorbeelden
In het volgende codevoorbeeld ziet u een klasse die een URL-specifieke eigenschap implementeert. In dit codevoorbeeld wordt een standaardkenmerk UrlPropertyAttribute toegepast op de TargetUrl eigenschap van de CustomHyperLinkControl klasse. Het kenmerk geeft ondersteuning aan voor alle URL-typen en geeft een standaardbestandsfilter op dat is ingesteld op *.*.
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
Opmerkingen
Een standaardexemplaren van de UrlPropertyAttribute klasse worden geïnitialiseerd met de Filter eigenschap ingesteld op de waarde *.*.
Van toepassing op
UrlPropertyAttribute(String)
Initialiseert een nieuw exemplaar van de UrlPropertyAttribute klasse, waarbij de Filter eigenschap wordt ingesteld op de opgegeven tekenreeks.
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)
Parameters
- filter
- String
Een bestandsfilter dat is gekoppeld aan de URL-specifieke eigenschap.
Voorbeelden
In het volgende codevoorbeeld ziet u een klasse die een URL-specifieke eigenschap implementeert. In dit codevoorbeeld wordt een UrlPropertyAttribute kenmerk toegepast op de TargetUrl eigenschap van de CustomHyperLinkControl klasse. Met het kenmerk wordt een specifiek bestandsfilter ingesteld voor ASP.NET bestanden.
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
Opmerkingen
Een exemplaar van een UrlPropertyAttribute klasse die met deze constructor is gemaakt, wordt geïnitialiseerd met de Filter eigenschap ingesteld op filter.