ControlDesigner.GetErrorDesignTimeHtml(Exception) 方法

定义

检索 HTML 标记,该标记提供有关指定异常的信息。

protected:
 virtual System::String ^ GetErrorDesignTimeHtml(Exception ^ e);
protected virtual string GetErrorDesignTimeHtml (Exception e);
abstract member GetErrorDesignTimeHtml : Exception -> string
override this.GetErrorDesignTimeHtml : Exception -> string
Protected Overridable Function GetErrorDesignTimeHtml (e As Exception) As String

参数

e
Exception

发生的异常。

返回

String

指定的异常的设计时 HTML 标记。

示例

下面的代码示例演示如何在发生错误并调用 CreatePlaceHolderDesignTimeHtml 方法时为控件生成设计时 HTML 标记。

// Generate the design-time markup for the control when an error occurs.
protected override string GetErrorDesignTimeHtml(Exception e) 
{
    // Write the error message text in red, bold.
    string errorRendering =
        "<span style=\"font-weight:bold; color:Red; \">" +
        e.Message + "</span>";

    return CreatePlaceHolderDesignTimeHtml(errorRendering);
} // GetErrorDesignTimeHtml
' Generate the design-time markup for the control when an error occurs.
Protected Overrides Function GetErrorDesignTimeHtml( _
    ByVal ex As Exception) As String

    ' Write the error message text in red, bold.
    Dim errorRendering As String = _
        "<span style=""font-weight:bold; color:Red; "">" & _
        ex.Message & "</span>"

    Return CreatePlaceHolderDesignTimeHtml(errorRendering)

End Function ' GetErrorDesignTimeHtml

注解

GetErrorDesignTimeHtml如果方法中GetDesignTimeHtml引发异常,则通常调用该方法。

继承者说明

典型的设计模式是尝试通过关联的控件获取 HTML 标记,然后如果遇到错误,请调用 GetErrorDesignTimeHtml(Exception) 该方法。 如果控件未返回任何标记,则调用 GetEmptyDesignTimeHtml() 该方法(如果未重写该方法以提供特定标记),则调用 CreatePlaceHolderDesignTimeHtml() 该方法,该方法应包含有关控件类型和 ID 的信息。

适用于

另请参阅