Share via


ControlValuePropertyAttribute 생성자

정의

ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다.

오버로드

ControlValuePropertyAttribute(String)

지정한 속성 이름을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다.

ControlValuePropertyAttribute(String, Object)

지정된 속성 이름과 기본값을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다.

ControlValuePropertyAttribute(String, Type, String)

지정된 속성 이름과 기본값을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다. 기본값은 또한 지정된 데이터 형식으로 변환됩니다.

ControlValuePropertyAttribute(String)

지정한 속성 이름을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다.

public:
 ControlValuePropertyAttribute(System::String ^ name);
public ControlValuePropertyAttribute (string name);
new System.Web.UI.ControlValuePropertyAttribute : string -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String)

매개 변수

name
String

컨트롤의 기본 속성입니다.

예제

다음 코드 예제에 적용 하는 방법을 보여 줍니다.는 ControlValuePropertyAttribute 사용자 지정 컨트롤에 기본 속성을 지정 하는 특성입니다. 이 생성자를 만들려면 ASP.NET에서 내부적으로 호출을 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")]
    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")> 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

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 ControlValuePropertyAttribute 클래스 지정된 된 속성 이름을 사용 합니다. 다음 표에서 인스턴스에 대 한 초기 속성 값을 ControlValuePropertyAttribute 클래스입니다.

속성 초기 값
Name name 매개 변수의 값입니다.

추가 정보

적용 대상

ControlValuePropertyAttribute(String, Object)

지정된 속성 이름과 기본값을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다.

public:
 ControlValuePropertyAttribute(System::String ^ name, System::Object ^ defaultValue);
public ControlValuePropertyAttribute (string name, object defaultValue);
new System.Web.UI.ControlValuePropertyAttribute : string * obj -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String, defaultValue As Object)

매개 변수

name
String

컨트롤의 기본 속성입니다.

defaultValue
Object

기본 속성의 기본값입니다.

예제

다음 코드 예제에 적용 하는 방법을 보여 줍니다.는 ControlValuePropertyAttribute 기본 속성 및 사용자 지정 컨트롤에 값을 지정 하는 특성입니다. 이 생성자를 만들려면 ASP.NET에서 내부적으로 호출을 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

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 ControlValuePropertyAttribute 클래스는 지정 된 속성 이름 및 기본 값을 사용 합니다. 다음 표에서는 ControlValuePropertyAttribute 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Name name 매개 변수의 값입니다.
DefaultValue defaultValue 매개 변수의 값입니다.

추가 정보

적용 대상

ControlValuePropertyAttribute(String, Type, String)

지정된 속성 이름과 기본값을 사용하여 ControlValuePropertyAttribute 클래스의 새 인스턴스를 초기화합니다. 기본값은 또한 지정된 데이터 형식으로 변환됩니다.

public:
 ControlValuePropertyAttribute(System::String ^ name, Type ^ type, System::String ^ defaultValue);
public ControlValuePropertyAttribute (string name, Type type, string defaultValue);
new System.Web.UI.ControlValuePropertyAttribute : string * Type * string -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String, type As Type, defaultValue As String)

매개 변수

name
String

컨트롤의 기본 속성입니다.

type
Type

기본값이 변환될 Type입니다.

defaultValue
String

기본 속성의 기본값입니다.

설명

새 인스턴스를 만들려면이 생성자를 사용 합니다 ControlValuePropertyAttribute 클래스는 지정 된 속성 이름 및 기본 값을 사용 합니다. 이 버전의 생성자는 또한 기본 값에서 지정한 데이터 형식으로 변환 하려고 합니다 type 매개 변수입니다. 기본 값을 변환할 수 없는 경우는 DefaultValue 속성이 설정 되지 않았습니다. 다음 표에서는 ControlValuePropertyAttribute 클래스의 인스턴스에 대한 초기 속성 값을 보여 줍니다.

속성 초기 값
Name name 매개 변수의 값입니다.
DefaultValue 값을 defaultValue 매개 변수를 값으로 지정 된 데이터 형식으로 변환할 수 있으면는 type 매개 변수입니다.

추가 정보

적용 대상