다음을 통해 공유


HyperLinkDataBindingHandler.DataBindControl(IDesignerHost, Control) 메서드

정의

지정된 컨트롤에 대한 디자인 타임 데이터 바인딩을 확인합니다.

public:
 override void DataBindControl(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::Web::UI::Control ^ control);
public override void DataBindControl(System.ComponentModel.Design.IDesignerHost designerHost, System.Web.UI.Control control);
override this.DataBindControl : System.ComponentModel.Design.IDesignerHost * System.Web.UI.Control -> unit
Public Overrides Sub DataBindControl (designerHost As IDesignerHost, control As Control)

매개 변수

designerHost
IDesignerHost

IDesignerHost 컨트롤이 들어 있는 문서의 경우입니다.

control
Control

Control to 데이터 바인딩입니다.

예제

다음 코드 예제에서는 클래스에서 파생되는 명명 CustomHyperLinkDataBindingHandler된 클래스를 HyperLinkDataBindingHandler 만듭니다. 디자인 타임에 데이터에 바인딩된 경우 개체 틀 텍스트가 속성 CustomHyperLink 에 대해 표시되도록 클래스의 속성에 대한 디자인 타임 데이터 바인딩 ImageUrl 을 확인합니다.

// Derive a class from the HyperLinkDataBindingHandler. It will 
// resolve  data binding for the CustomHyperlink at design time.
public class CustomHyperLinkDataBindingHandler : 
    HyperLinkDataBindingHandler
{
    // Override the DataBindControl to set property values in  
    // the DataBindingCollection at design time.
    public override void DataBindControl(IDesignerHost designerHost, 
        Control control)
    {
        DataBindingCollection bindings = 
            ((IDataBindingsAccessor)control).DataBindings;
        DataBinding imageBinding = bindings["ImageUrl"];

           // If Text is empty, supply a default value.
        if (!(imageBinding == null))
        {
            CustomHyperLink hype = (CustomHyperLink)control;
            hype.ImageUrl = "Image URL.";
        }

        // Call the base method to bind the control.
        base.DataBindControl(designerHost, control);
    } // DataBindControl
} // CustomHyperLinkDataBindingHandler
' Derive a class from the HyperLinkDataBindingHandler. It will 
' resolve  data binding for the CustomHyperlink at design time.
Public Class CustomHyperLinkDataBindingHandler
    Inherits HyperLinkDataBindingHandler

    ' Override the DataBindControl to set property values in  
    ' the DataBindingCollection at design time.
    Public Overrides Sub DataBindControl( _
        ByVal designerHost As IDesignerHost, ByVal control As Control)

        Dim bindings As DataBindingCollection = _
            CType(control, IDataBindingsAccessor).DataBindings
        Dim imageBinding As DataBinding = bindings("ImageUrl")

        If Not (imageBinding Is Nothing) Then
            Dim hLink As CustomHyperLink = CType(control, CustomHyperLink)
            hLink.ImageUrl = "Image URL."
        End If

        MyBase.DataBindControl(designerHost, control)
    End Sub
End Class

설명

이 메서드는 컨트롤의 TextHyperLink 속성 및 NavigateUrl 데이터 바인딩 여부를 결정 합니다. 속성이 Text 데이터 바인딩된 경우 이 메서드는 속성 값을 "DataBound"로 설정합니다. 속성이 NavigateUrl 데이터 바인딩된 경우 이 메서드는 컨트롤이 작동하는 하이퍼링크의 모양을 갖도록 속성 값을 텍스트 문자열로 설정합니다.

적용 대상