LoginDesigner.GetErrorDesignTimeHtml(Exception) 方法

定義

在設計階段發生錯誤時,提供用來呈現關聯控制項的標記。

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

參數

e
Exception

擲回的是 Exception

傳回

包含標記的字串,此標記可用來在設計階段發生錯誤之後呈現關聯的 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 控制項轉譯的預留位置包含類型名稱、控制項名稱和宣告和描述錯誤的訊息。

適用於

另請參閱