LoginStatusDesigner.GetDesignTimeHtml 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 den markering som används för att återge den associerade kontrollen vid designtillfället.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Returer
En sträng som innehåller den markering som används för att återge vid LoginStatus designtillfället.
Exempel
I följande kodexempel visas hur du åsidosätter GetDesignTimeHtml metoden i en klass som ärvs från LoginStatusDesigner klassen för att ändra utseendet på en kontroll som härleds från LoginStatus klassen vid designtillfället. Exemplet ritar en blå, streckad kantlinje runt kontrollen för att göra dess omfattning mer synlig, om BorderStyle kontrollens egenskap är NotSet värdet eller None .
// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
// Make the control more visible in the designer. If the border
// style is None or NotSet, change the border to a blue dashed line.
MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl;
string markup = null;
// Check if the border style should be changed.
if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet ||
myLoginStatusCtl.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle;
Color oldBorderColor = myLoginStatusCtl.BorderColor;
// Set the design time properties and catch any exceptions.
try
{
myLoginStatusCtl.BorderStyle = BorderStyle.Dashed;
myLoginStatusCtl.BorderColor = Color.Blue;
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
markup = GetErrorDesignTimeHtml(ex);
}
finally
{
// It is not necessary to restore the border properties
// to their original values because the ViewControl
// was used to reference the associated control and the
// UsePreviewControl was not overridden.
// myLoginCtl.BorderStyle = oldBorderStyle;
// myLoginCtl.BorderColor = oldBorderColor;
}
}
else
{
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Public Overrides Function GetDesignTimeHtml() As String
' Make the control more visible in the designer. If the border
' style is None or NotSet, change the border to a blue dashed line.
Dim myLoginStatusCtl As MyLoginStatus = _
CType(ViewControl, MyLoginStatus)
Dim markup As String = Nothing
' Check if the border style should be changed.
If (myLoginStatusCtl.BorderStyle = BorderStyle.NotSet Or _
myLoginStatusCtl.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myLoginStatusCtl.BorderStyle
Dim oldBorderColor As Color = myLoginStatusCtl.BorderColor
' Set the design time properties and catch any exceptions.
Try
myLoginStatusCtl.BorderStyle = BorderStyle.Dashed
myLoginStatusCtl.BorderColor = Color.Blue
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
Catch ex As Exception
markup = GetErrorDesignTimeHtml(ex)
Finally
' It is not necessary to restore the border properties
' to their original values because the ViewControl
' was used to reference the associated control and the
' UsePreviewControl was not overridden.
' myLoginCtl.BorderStyle = oldBorderStyle
' myLoginCtl.BorderColor = oldBorderColor
End Try
Else
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
End If
Return markup
End Function ' GetDesignTimeHtml
Kommentarer
LogoutText Om egenskapen eller LoginText (beroende på om användaren är inloggad) är , är nullen tom sträng (""), eller ett enda blanksteg (" "), GetDesignTimeHtml anger LogoutText metoden egenskapen ellerLoginText, efter behov, egenskapen ID inom hakparenteser ("[ ]"). Oavsett inställningen LoginText för eller LogoutTextGetDesignTimeHtml anropar GetDesignTimeHtml metoden sedan basmetoden för att generera markering för designtidsåtergivningen LoginStatus av kontrollen.
Anteckningar till arvingar
Om du åsidosätter GetDesignTimeHtml() metoden måste du anropa GetDesignTimeHtml() basmetoden eftersom den så småningom, via flera åsidosättningsnivåer, anropar LoginStatus kontrollen eller en kopia av kontrollen för att generera pålägget.