英語で読む

次の方法で共有


UrlPropertyAttribute コンストラクター

定義

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

オーバーロード

UrlPropertyAttribute()

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

UrlPropertyAttribute(String)

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

UrlPropertyAttribute()

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

C#
public UrlPropertyAttribute ();

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

C#
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.
}

注釈

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

適用対象

.NET Framework 4.8 およびその他のバージョン
製品 バージョン
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

UrlPropertyAttribute(String)

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

C#
public UrlPropertyAttribute (string filter);

パラメーター

filter
String

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

次のコード例は、URL 固有のプロパティを実装するクラスを示しています。 このコード例では、UrlPropertyAttribute属性がクラスのプロパティにTargetUrl``CustomHyperLinkControl適用されます。 この属性は、ASP.NET ファイルの特定のファイル フィルターを設定します。

C#
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.
}

注釈

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

適用対象

.NET Framework 4.8 およびその他のバージョン
製品 バージョン
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8