UrlPropertyAttribute コンストラクター

定義

UrlPropertyAttribute クラスの新しいインスタンスを初期化します。

オーバーロード

UrlPropertyAttribute()

UrlPropertyAttribute クラスの新しい既定のインスタンスを初期化します。

UrlPropertyAttribute(String)

UrlPropertyAttribute クラスの新しいインスタンスを初期化し、Filter プロパティを指定した文字列に設定します。

UrlPropertyAttribute()

UrlPropertyAttribute クラスの新しい既定のインスタンスを初期化します。

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

次のコード例は、URL 固有のプロパティを実装するクラスを示しています。 このコード例では、クラスのプロパティにTargetUrl既定UrlPropertyAttributeの属性がCustomHyperLinkControl適用されます。 この属性は、すべての URL の種類のサポートを示し、既定のファイル フィルターを "*.*" に設定します。

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

注釈

クラスの既定の UrlPropertyAttribute インスタンスは、プロパティが Filter 値 "*.*" に設定されて初期化されます。

適用対象

UrlPropertyAttribute(String)

UrlPropertyAttribute クラスの新しいインスタンスを初期化し、Filter プロパティを指定した文字列に設定します。

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)

パラメーター

filter
String

URL 固有のプロパティに関連付けられたファイル フィルター。

次のコード例は、URL 固有のプロパティを実装するクラスを示しています。 このコード例では、UrlPropertyAttribute属性がクラスのプロパティにTargetUrl``CustomHyperLinkControl適用されます。 この属性は、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

注釈

このコンストラクターで作成されたUrlPropertyAttributeクラスのインスタンスは、プロパティfilterFilter .

適用対象