ControlDesigner.GetDesignTimeHtml 메서드

정의

디자인 타임에 컨트롤을 나타내는 데 사용되는 HTML 태그를 검색합니다.

오버로드

GetDesignTimeHtml(DesignerRegionCollection)

컨트롤을 표시하는 HTML 태그를 가져와서 현재 컨트롤 디자이너 영역을 사용하여 컬렉션을 채웁니다.

GetDesignTimeHtml()

디자인 타임에 컨트롤을 나타내는 데 사용되는 HTML 태그를 검색합니다.

GetDesignTimeHtml(DesignerRegionCollection)

컨트롤을 표시하는 HTML 태그를 가져와서 현재 컨트롤 디자이너 영역을 사용하여 컬렉션을 채웁니다.

public:
 virtual System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public virtual string GetDesignTimeHtml (System.Web.UI.Design.DesignerRegionCollection regions);
abstract member GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overridable Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String

매개 변수

regions
DesignerRegionCollection

연결된 컨트롤에 대한 컨트롤 디자이너 영역의 컬렉션입니다.

반환

String

모든 컨트롤 디자이너 영역을 포함하여 연결된 컨트롤에 대한 디자인 타임 HTML 태그입니다.

예제

다음 코드 예제에서는 컬렉션을 사용 하 여 HTML 태그를 만드는 방법을 보여 줍니다 DesignerRegionCollection .

// Create the regions and design-time markup. Called by the designer host.
public override String GetDesignTimeHtml(DesignerRegionCollection regions) {
    // Create 3 regions: 2 clickable headers and an editable row
    regions.Add(new DesignerRegion(this, "Header0"));
    regions.Add(new DesignerRegion(this, "Header1"));

    // Create an editable region and add it to the regions
    EditableDesignerRegion editableRegion = 
        new EditableDesignerRegion(this, 
            "Content" + myControl.CurrentView, false);
    regions.Add(editableRegion);

    // Set the highlight for the selected region
    regions[myControl.CurrentView].Highlight = true;

    // Use the base class to render the markup
    return base.GetDesignTimeHtml();
}
' Create the regions and design-time markup. Called by the designer host.
Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String
    ' Create 3 regions: 2 clickable headers and an editable row
    regions.Add(New DesignerRegion(Me, "Header0"))
    regions.Add(New DesignerRegion(Me, "Header1"))

    ' Create an editable region and add it to the regions
    Dim editableRegion As EditableDesignerRegion = _
        New EditableDesignerRegion(Me, _
            "Content" & myControl.CurrentView, False)
    regions.Add(editableRegion)

    ' Set the highlight for the selected region
    regions(myControl.CurrentView).Highlight = True

    ' Use the base class to render the markup
    Return MyBase.GetDesignTimeHtml()
End Function

설명

디자인 호스트는 메서드를 GetDesignTimeHtml 호출하여 디자인 타임 HTML 태그와 현재 컨트롤 디자이너 영역 목록을 가져옵니다. 디자이너RegionCollection을 사용하여 디자인 호스트는 편집 가능한 각 컨트롤 디자이너 지역에 대한 태그를 요청할 수 있습니다.

GetDesignTimeHtml 메서드는 메서드를 호출하기 전에 해당 지역의 콘텐츠를 처리해야 하는 클래스와 같은 GridViewDesigner 파생 컨트롤 디자이너에 GetDesignTimeHtml 대해 제공됩니다.

추가 정보

적용 대상

GetDesignTimeHtml()

디자인 타임에 컨트롤을 나타내는 데 사용되는 HTML 태그를 검색합니다.

public:
 virtual System::String ^ GetDesignTimeHtml();
public virtual string GetDesignTimeHtml ();
abstract member GetDesignTimeHtml : unit -> string
override this.GetDesignTimeHtml : unit -> string
Public Overridable Function GetDesignTimeHtml () As String

반환

String

디자인 타임에 컨트롤을 나타낼 HTML 태그입니다.

예제

다음 코드 예제에서는 사용자 지정 컨트롤 디자이너에서 메서드를 재정의 GetDesignTimeHtml 하는 방법을 보여 줍니다. 연결된 컨트롤의 Text 속성이 비어 있으면 메서드가 GetDesignTimeHtml 메서드를 호출합니다 GetEmptyDesignTimeHtml . 그렇지 않으면 메서드가 GetDesignTimeHtml 하이퍼링크 컨트롤을 만들고 렌더링합니다.

public override string GetDesignTimeHtml()
{
    if (simpleControl.Text.Length > 0)
    {
        string spec = "<a href='{0}.aspx'>{0}</a>";
        return String.Format(spec, simpleControl.Text);
    }
    else
    {
        return GetEmptyDesignTimeHtml();
    }
}
Public Overrides Function GetDesignTimeHtml() As String
   ' Component is the instance of the component or control that
   ' this designer object is associated with. This property is 
   ' inherited from System.ComponentModel.ComponentDesigner.
   simpleControl = CType(Component, Simple)
   
   If simpleControl.Text.Length > 0 Then
      Dim sw As New StringWriter()
      Dim tw As New HtmlTextWriter(sw)
      
      Dim placeholderLink As New HyperLink()
      
      ' Put simpleControl.Text into the link's Text.
      placeholderLink.Text = simpleControl.Text
      placeholderLink.NavigateUrl = simpleControl.Text
      placeholderLink.RenderControl(tw)
      
      Return sw.ToString()
   Else
      Return GetEmptyDesignTimeHtml()
   End If
End Function

상속자 참고

사용자 지정 컨테이너 컨트롤을 만드는 경우 속성이 설정되었는지 여부에 관계없이 디자인 타임에 컨트롤 및 모든 자식 컨트롤을 Visible 렌더링해야 합니다 true false.

추가 정보

적용 대상