LoginDesigner.GetErrorDesignTimeHtml(Exception) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供標記,用於在設計時錯誤發生時渲染相關控制。
protected:
override System::String ^ GetErrorDesignTimeHtml(Exception ^ e);
protected override string GetErrorDesignTimeHtml(Exception e);
override this.GetErrorDesignTimeHtml : Exception -> string
Protected Overrides Function GetErrorDesignTimeHtml (e As Exception) As String
參數
傳回
包含標記的字串,用於在錯誤發生後渲染設計時的相關標記 Login 。
範例
以下程式碼範例展示了如何在繼承自該GetErrorDesignTimeHtml類別的類別中覆寫該LoginDesigner方法,以改變設計時從控制Login項衍生出的控制項外觀。 範例中會產生一個佔位符的標記,該標記包含以紅色粗體字呈現的錯誤訊息。
// 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
備註
設計時 Login 控制所渲染的佔位符包含型別名稱、控制名稱,以及宣告和描述錯誤的訊息。