ControlDesigner.GetErrorDesignTimeHtml(Exception) Metodo

Definizione

Recupera il markup HTML che fornisce informazioni sull'eccezione specificata.

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

Parametri

e
Exception

Eccezione che si è verificata.

Restituisce

String

Markup HTML della fase di progettazione per l'eccezione specificata.

Esempio

Nell'esempio di codice seguente viene illustrato come generare markup HTML in fase di progettazione per il controllo quando si verifica un errore e chiamare il CreatePlaceHolderDesignTimeHtml metodo .

// 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

Commenti

Il GetErrorDesignTimeHtml metodo viene in genere chiamato, se viene generata un'eccezione nel GetDesignTimeHtml metodo .

Note per gli eredi

Il modello di progettazione tipico consiste nel cercare di ottenere markup HTML tramite il controllo associato e quindi, se viene rilevato un errore, chiamare il GetErrorDesignTimeHtml(Exception) metodo . Se non viene restituito alcun markup dal controllo, chiamare il GetEmptyDesignTimeHtml() metodo , che se non viene sottoposto a override per fornire markup specifico, chiama il CreatePlaceHolderDesignTimeHtml() metodo , che deve contenere informazioni sul tipo e l'ID del controllo.

Si applica a

Vedi anche