BaseValidatorDesigner.GetDesignTimeHtml Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém a marcação que é usada para renderizar o controlo associado no momento do design.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Devoluções
Uma string contendo a marcação usada para renderizar o BaseValidator momento do design.
Exemplos
O exemplo de código seguinte mostra como sobrescrever o GetDesignTimeHtml método que desenha uma borda sólida em torno do controlo associado no momento do projeto se o valor da BorderStyle propriedade do controlo for definido para o NotSet campo ou None .
// 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
Observações
Se a ErrorMessage propriedade ou Text do controlo associado derivado da BaseValidator classe for uma cadeia vazia (""), ou se a Display propriedade for definida para o None campo, o GetDesignTimeHtml método define a ErrorMessage propriedade para o ID de controlo, que está entre parênteses ([]) e define a Display propriedade para o Static campo. Depois, GetDesignTimeHtml chama o GetDesignTimeHtml método base para gerar a marcação e restaura as propriedades de controlo aos seus valores originais, se necessário.