BaseValidatorDesigner.GetDesignTimeHtml Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de opmaak op die wordt gebruikt om het bijbehorende besturingselement op het ontwerptijd weer te geven.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Retouren
Een tekenreeks met de markeringen die worden gebruikt om de BaseValidator ontwerptijd weer te geven.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de GetDesignTimeHtml methode overschrijft waarmee een ononderbroken rand rond het bijbehorende besturingselement tijdens het ontwerptijd wordt opgehaald als de waarde van de BorderStyle eigenschap van het besturingselement is ingesteld op het NotSet of None veld.
// Make the full extent of the control more visible in the designer.
// If the border style is None or NotSet, change the border to a
// solid line.
public override string GetDesignTimeHtml()
{
// Get a reference to the control or a copy of the control.
SimpleCompareValidator myCV = (SimpleCompareValidator)ViewControl;
string markup = null;
// Check if the border style should be changed.
if (myCV.BorderStyle == BorderStyle.NotSet ||
myCV.BorderStyle == BorderStyle.None)
{
// Save the current property setting.
BorderStyle oldBorderStyle = myCV.BorderStyle;
// Set the design-time property and catch any exceptions.
try
{
myCV.BorderStyle = BorderStyle.Solid;
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
markup = GetErrorDesignTimeHtml(ex);
}
finally
{
// Restore the property to its original setting.
myCV.BorderStyle = oldBorderStyle;
}
}
else
{
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
return markup;
} // GetDesignTimeHtml
' Make the full extent of the control more visible in the designer.
' If the border style is None or NotSet, change the border to a
' solid line.
Public Overrides Function GetDesignTimeHtml() As String
' Get a reference to the control or a copy of the control.
Dim myCV As SimpleCompareValidator = _
CType(ViewControl, SimpleCompareValidator)
Dim markup As String
' Check if the border style should be changed.
If (myCV.BorderStyle = BorderStyle.NotSet Or _
myCV.BorderStyle = BorderStyle.None) Then
' Save the current property setting.
Dim oldBorderStyle As BorderStyle = myCV.BorderStyle
' Set the design-time property and catch any exceptions.
Try
myCV.BorderStyle = BorderStyle.Solid
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
Catch ex As Exception
markup = GetErrorDesignTimeHtml(ex)
Finally
' Restore the property to its original setting.
myCV.BorderStyle = oldBorderStyle
End Try
Else
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
End If
Return markup
End Function
Opmerkingen
Als de ErrorMessage of Text eigenschap van het bijbehorende besturingselement dat is afgeleid van de BaseValidator klasse een lege tekenreeks ("") is of als de Display eigenschap is ingesteld op het None veld, stelt de methode de GetDesignTimeHtmlErrorMessage eigenschap in op de besturingselement-id, die tussen vierkante haken ([]) staat en de Display eigenschap instelt op het Static veld. Vervolgens GetDesignTimeHtml wordt de GetDesignTimeHtml basismethode aangeroepen om de markeringen te genereren en worden de besturingselementeigenschappen indien nodig hersteld naar de oorspronkelijke waarden.