다음을 통해 공유


DataListDesigner.GetDesignTimeHtml 메서드

정의

디자인 타임에 DataList 컨트롤을 나타내는 데 사용되는 HTML을 가져옵니다.

public:
 override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String

반환

디자인 타임에 DataList 컨트롤을 나타내는 데 사용되는 HTML입니다.

예제

다음 코드 예제는 메서드를 재정의 GetDesignTimeHtml 하는 방법을 보여줍니다. 컨트롤의 속성이 인 경우 디자인 화면에서 컨트롤의 WebControl.Enabled 모양을 변경합니다 true.

이 코드는 구문을 사용하여 Try...Catch...Finally 다음을 수행합니다.

  • 섹션은 Try 컨트롤의 속성 값을 변경합니다.

  • 섹션은 Catch 예외를 catch하고 메서드로 GetErrorDesignTimeHtml 보냅니다.

  • 섹션은 Finally 속성을 원래 값으로 설정합니다.

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 DataListDesigner 클래스입니다.

public override string GetDesignTimeHtml()
{
    string designTimeHtml = String.Empty;

    simpleGView = (SimpleGridView)Component;

    // Check the control's BorderStyle property to  
    // conditionally render design-time HTML.
    if (simpleGView.BorderStyle == BorderStyle.NotSet)
    {
        // Save the current property settings in variables.
        int oldCellPadding = simpleGView.CellPadding;
        Unit oldBorderWidth = simpleGView.BorderWidth;
        Color oldBorderColor = simpleGView.BorderColor;

        // Set properties and generate the design-time HTML.
        try
        {
            simpleGView.Caption = "SimpleGridView";
            simpleGView.CellPadding = 1;
            simpleGView.BorderWidth = Unit.Pixel(3);
            simpleGView.BorderColor = Color.Red;

            designTimeHtml = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            // Get HTML from the GetErrorDesignTimeHtml 
            // method if an exception occurs.
            designTimeHtml = GetErrorDesignTimeHtml(ex);

            // Return the properties to their original values.
        }
        finally
        {
            simpleGView.CellPadding = oldCellPadding;
            simpleGView.BorderWidth = oldBorderWidth;
            simpleGView.BorderColor = oldBorderColor;
        }
    }
    else
    {
        designTimeHtml = base.GetDesignTimeHtml();
    }

    return designTimeHtml;
}

protected override string
    GetErrorDesignTimeHtml(System.Exception exc)
{
    return CreatePlaceHolderDesignTimeHtml(
        "ASPNET.Examples: An error occurred while rendering the GridView.");
}
Public Overrides Function GetDesignTimeHtml() As String
    Dim designTimeHtml As String = String.Empty

    simpleGView = CType(Component, SimpleGridView)

    ' Check the control's BorderStyle property to  
    ' conditionally render design-time HTML.
    If (simpleGView.BorderStyle = BorderStyle.NotSet) Then
        ' Save the current property settings in variables.
        Dim oldCellPadding As Integer = simpleGView.CellPadding
        Dim oldBorderWidth As Unit = simpleGView.BorderWidth
        Dim oldBorderColor As Color = simpleGView.BorderColor

        ' Set properties and generate the design-time HTML.
        Try
            simpleGView.Caption = "SimpleGridView"
            simpleGView.CellPadding = 1
            simpleGView.BorderWidth = Unit.Pixel(3)
            simpleGView.BorderColor = Color.Red

            designTimeHtml = MyBase.GetDesignTimeHtml()

        Catch ex As Exception
            ' Get HTML from the GetErrorDesignTimeHtml 
            ' method if an exception occurs.
            designTimeHtml = GetErrorDesignTimeHtml(ex)

            ' Return the properties to their original values.
        Finally
            simpleGView.CellPadding = oldCellPadding
            simpleGView.BorderWidth = oldBorderWidth
            simpleGView.BorderColor = oldBorderColor
        End Try

    Else
        designTimeHtml = MyBase.GetDesignTimeHtml()
    End If

    Return designTimeHtml
End Function

Protected Overrides Function _
    GetErrorDesignTimeHtml(ByVal exc As Exception) As String

    Return CreatePlaceHolderDesignTimeHtml( _
        "ASPNET.Examples: An error occurred while rendering the GridView.")

End Function

적용 대상

추가 정보