UrlPropertyAttribute クラス

定義

コントロールで URL 値を含む文字列プロパティを識別するために使用される属性を定義します。 このクラスは継承できません。

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
継承
UrlPropertyAttribute
属性

次のコード例は、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 属性は、URL を表すコントロール プロパティに適用される属性です。 この属性は、文字列プロパティを URL を表すものとしてマークするだけでなく、 UrlPropertyAttribute プロパティに Filter 対してフィルター処理するために使用できる特定のファイルの種類を識別するプロパティを定義します。

コンストラクター

UrlPropertyAttribute()

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

UrlPropertyAttribute(String)

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

プロパティ

Filter

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

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

GetHashCode()

このインスタンスのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象