ControlDesigner.GetErrorDesignTimeHtml(Exception) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar HTML-koden som innehåller information om det angivna undantaget.
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
Parametrar
Undantaget som inträffade.
Returer
HTML-kod för designtid för det angivna undantaget.
Exempel
Följande kodexempel visar hur du genererar HTML-kod för designtid för kontrollen när ett fel inträffar och anropar CreatePlaceHolderDesignTimeHtml metoden.
// 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
Kommentarer
Metoden GetErrorDesignTimeHtml anropas vanligtvis om ett undantag genereras i GetDesignTimeHtml metoden.
Anteckningar till arvingar
Det typiska designmönstret är att försöka hämta HTML-kod via den associerade kontrollen och sedan anropa GetErrorDesignTimeHtml(Exception) metoden om ett fel påträffas. Om ingen markering returneras av kontrollen anropar du GetEmptyDesignTimeHtml() metoden, som om den inte åsidosättas för att ange specifik markering anropar CreatePlaceHolderDesignTimeHtml() metoden, som bör innehålla information om kontrollens typ och ID.