ControlDesigner.GetErrorDesignTimeHtml(Exception) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得提供指定例外資訊的 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
參數
那個例外發生了。
傳回
設計時 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() 方法;若未覆蓋以提供特定標記,則呼叫 CreatePlaceHolderDesignTimeHtml() 該方法,該方法應包含控制項的類型與 ID 資訊。