ControlDesigner.GetErrorDesignTimeHtml(Exception) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Načte kód HTML, který poskytuje informace o zadané výjimce.
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
Parametry
Došlo k výjimce.
Návraty
Kód HTML v době návrhu pro zadanou výjimku.
Příklady
Následující příklad kódu ukazuje, jak vygenerovat kód HTML návrhu pro ovládací prvek, když dojde k chybě a zavolá metodu CreatePlaceHolderDesignTimeHtml .
// 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
Poznámky
Metoda GetErrorDesignTimeHtml se obvykle volá, pokud je v GetDesignTimeHtml metodě vyvolána výjimka.
Poznámky pro dědice
Typickým vzorem návrhu je pokusit se získat kód HTML prostřednictvím přidruženého ovládacího prvku a potom, pokud dojde k chybě, zavolejte metodu GetErrorDesignTimeHtml(Exception) . Pokud ovládací prvek nevrátí žádné revize, zavolejte metodu GetEmptyDesignTimeHtml() , která pokud není přepsána, aby poskytovala konkrétní revize, volá metodu CreatePlaceHolderDesignTimeHtml() , která by měla obsahovat informace o typu a ID ovládacího prvku.