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

発生した例外。

返品

指定した例外のデザイン時 HTML マークアップ。

次のコード例では、エラーが発生したときにコントロールのデザイン時 HTML マークアップを生成し、 CreatePlaceHolderDesignTimeHtml メソッドを呼び出す方法を示します。

// 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() メソッドを呼び出します。特定のマークアップを提供するためにオーバーライドされていない場合は、コントロールの型と ID に関する情報を含む CreatePlaceHolderDesignTimeHtml() メソッドを呼び出します。

適用対象

こちらもご覧ください