Aracılığıyla paylaş


UrlPropertyAttribute Oluşturucular

Tanım

UrlPropertyAttribute sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

UrlPropertyAttribute()

sınıfının yeni bir varsayılan örneğini UrlPropertyAttribute başlatır.

UrlPropertyAttribute(String)

özelliğini belirtilen dizeye UrlPropertyAttribute ayarlayarak Filter sınıfının yeni bir örneğini başlatır.

UrlPropertyAttribute()

sınıfının yeni bir varsayılan örneğini UrlPropertyAttribute başlatır.

public:
 UrlPropertyAttribute();
public UrlPropertyAttribute ();
Public Sub New ()

Örnekler

Aşağıdaki kod örneği, URL'ye özgü özelliği uygulayan bir sınıfı gösterir. Bu kod örneğinde, sınıfının özelliğine TargetUrl CustomHyperLinkControl varsayılan UrlPropertyAttribute bir öznitelik uygulanır. özniteliği tüm URL türleri için desteği gösterir ve "**" olarak ayarlanmış bir varsayılan dosya filtresi belirtir.

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

Açıklamalar

Sınıfın UrlPropertyAttribute varsayılan örneği, özelliği "**" değerine ayarlanmış şekilde başlatılırFilter.

Şunlara uygulanır

UrlPropertyAttribute(String)

özelliğini belirtilen dizeye UrlPropertyAttribute ayarlayarak Filter sınıfının yeni bir örneğini başlatır.

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)

Parametreler

filter
String

URL'ye özgü özellik ile ilişkilendirilmiş bir dosya filtresi.

Örnekler

Aşağıdaki kod örneği, URL'ye özgü özelliği uygulayan bir sınıfı gösterir. Bu kod örneğinde, sınıfının özelliğine TargetUrl CustomHyperLinkControl bir UrlPropertyAttribute öznitelik uygulanır. özniteliği, ASP.NET dosyalar için belirli bir dosya filtresi ayarlar.

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

Açıklamalar

Bu oluşturucu ile oluşturulan bir UrlPropertyAttribute sınıfın örneği, özelliği olarak filterayarlanmış şekilde Filter başlatılır.

Şunlara uygulanır