다음을 통해 공유


ControlValuePropertyAttribute 생성자

정의

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

오버로드

Name Description
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 기본 속성을 지정 하는 특성을 적용 하는 방법을 보여 줍니다. 이 생성자는 특성을 나타내는 개체를 만들기 ControlValuePropertyAttribute 위해 ASP.NET 내부적으로 호출됩니다.


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 기본 속성 및 값을 지정 하는 특성을 적용 하는 방법을 보여 줍니다. 이 생성자는 특성을 나타내는 개체를 만들기 ControlValuePropertyAttribute 위해 ASP.NET 내부적으로 호출됩니다.


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 값입니다.

추가 정보

적용 대상