LoginViewDesigner.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
參數
傳回
包含標記的字串,用於在錯誤發生後渲染設計時的相關標記 LoginView 。
範例
以下程式碼範例說明如何覆寫 GetErrorDesignTimeHtml 從該類別繼承 LoginViewDesigner 的方法,以改變設計時從類別衍生出 LoginView 的控制項外觀。 範例中會產生包含錯誤訊息的佔位符標記,該錯誤訊息以紅色粗體字呈現。
// Generate the design-time markup for the control when an error occurs.
protected override string GetErrorDesignTimeHtml(Exception ex)
{
// Write the error message text in red, bold.
string errorRendering =
"<span style=\"font-weight:bold; color:Red; \">" +
ex.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
備註
錯誤設計時 LoginView 控制會以面板形式呈現,包含型別名稱、控制名稱,以及宣告和描述錯誤的訊息。