LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) 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 och fyller i en samling designerregioner.
public:
override System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public override string GetDesignTimeHtml(System.Web.UI.Design.DesignerRegionCollection regions);
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overrides Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String
Parametrar
- regions
- DesignerRegionCollection
En DesignerRegionCollection som definitioner av de valbara och klickbara regionerna i kontrollens designtidsvy läggs till.
Returer
En sträng som innehåller den markering som används för att återge vid Login designtillfället.
Exempel
I följande kodexempel visas hur du åsidosätter GetDesignTimeHtml metoden i en klass som ärvs från LoginDesigner klassen för att ändra utseendet på en kontroll som härleds från Login kontrollen 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.
MyLogin myLoginCtl = (MyLogin)ViewControl;
string markup = null;
// Check if the border style should be changed.
if (myLoginCtl.BorderStyle == BorderStyle.NotSet ||
myLoginCtl.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myLoginCtl.BorderStyle;
Color oldBorderColor = myLoginCtl.BorderColor;
// Set the design time properties and catch any exceptions.
try
{
myLoginCtl.BorderStyle = BorderStyle.Dashed;
myLoginCtl.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 myLoginCtl As MyLogin = CType(ViewControl, MyLogin)
Dim markup As String = Nothing
' Check if the border style should be changed.
If (myLoginCtl.BorderStyle = BorderStyle.NotSet Or _
myLoginCtl.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myLoginCtl.BorderStyle
Dim oldBorderColor As Color = myLoginCtl.BorderColor
' Set the design time properties and catch any exceptions.
Try
myLoginCtl.BorderStyle = BorderStyle.Dashed
myLoginCtl.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
Metoden GetDesignTimeHtml skapar ett EditableDesignerRegion objekt för egenskapen för LayoutTemplate den associerade Login kontrollen och lägger till det i DesignerRegionCollection objektet som refereras av parametern regions . Metoden GetDesignTimeHtml använder GetDesignTimeHtml basmetoden för att generera markering för kontrollens designtidsåtergivning Login .
Anteckningar till arvingar
Om du åsidosätter GetDesignTimeHtml(DesignerRegionCollection) metoden måste du anropa GetDesignTimeHtml() basmetoden eftersom den så småningom, via flera åsidosättningsnivåer, anropar Login kontrollen eller en kopia av kontrollen för att generera pålägget.