ControlValuePropertyAttribute クラス

定義

実行時に ControlParameter オブジェクトのバインド先となるコントロールの既定のプロパティを指定します。 このクラスは継承できません。

public ref class ControlValuePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class ControlValuePropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type ControlValuePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class ControlValuePropertyAttribute
Inherits Attribute
継承
ControlValuePropertyAttribute
属性

次のコード例では、既定のプロパティと値を ControlValuePropertyAttribute 指定する属性をカスタム コントロールに適用する方法を示します。


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Samples.AspNet.CS.Controls
{
    // Set ControlValueProperty attribute to specify the default
    // property of this control that a ControlParameter object 
    // binds to at run time.
    [DefaultProperty("Text")]
    [ControlValueProperty("Text", "Default Text")]
    public class SimpleCustomControl : WebControl
    {
        private string text;

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        public string Text
        {
            get
            {
                return text;
            }
            set
            {
                text = value;
            }
        }

        protected override void Render(HtmlTextWriter output)
        {
            output.Write(Text);
        }
    }
}

Imports System.ComponentModel
Imports System.Web.UI

Namespace Samples.AspNet.VB.Controls

    ' Set ControlValueProperty attribute to specify the default
    ' property of this control that a ControlParameter object 
    ' binds to at run time.
    <DefaultProperty("Text"), ControlValueProperty("Text", "DefaultText")> Public Class SimpleCustomControl
        Inherits System.Web.UI.WebControls.WebControl

        Dim _text As String

        <Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]() As String
            Get
                Return _text
            End Get

            Set(ByVal Value As String)
                _text = Value
            End Set
        End Property

        Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
            output.Write([Text])
        End Sub

    End Class

End Namespace

注釈

オブジェクトをControlParameter定義するときは、通常、 プロパティと PropertyName プロパティの両方を設定して、コントロールの プロパティをパラメーターにControlIDバインドします。 プロパティが PropertyName 設定されていない場合は、既定のプロパティが使用されます。 属性は ControlValuePropertyAttribute 、実行時にオブジェクトがバインドする既定のプロパティを ControlParameter 指定するためにコントロールに適用されます。

属性の使用の詳細については、「 属性」を参照してください。

ControlValuePropertyAttribute クラスのインスタンスの初期プロパティ値一覧については、ControlValuePropertyAttribute コンストラクターに関するトピックを参照してください。

コンストラクター

ControlValuePropertyAttribute(String)

指定したプロパティ名を使用して、ControlValuePropertyAttribute クラスの新しいインスタンスを初期化します。

ControlValuePropertyAttribute(String, Object)

指定したプロパティ名と既定値を使用して、ControlValuePropertyAttribute クラスの新しいインスタンスを初期化します。

ControlValuePropertyAttribute(String, Type, String)

指定したプロパティ名と既定値を使用して、ControlValuePropertyAttribute クラスの新しいインスタンスを初期化します。 既定値は指定したデータ型に変換されます。

プロパティ

DefaultValue

コントロールの既定のプロパティの既定値を取得します。

Name

コントロールの既定のプロパティを取得します。

TypeId

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

(継承元 Attribute)

メソッド

Equals(Object)

ControlValuePropertyAttribute オブジェクトの現在のインスタンスが指定したオブジェクトに等しいかどうかを判断します。

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)

適用対象

こちらもご覧ください