BaseValidatorDesigner.GetDesignTimeHtml Método

Definición

Obtiene el marcado que se usa para representar el control asociado en tiempo de diseño.

public:
 override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String

Devoluciones

Una cadena que contiene el formato utilizado para representar el control BaseValidator en tiempo de diseño.

Ejemplos

En el ejemplo de código siguiente se muestra cómo invalidar el GetDesignTimeHtml método que dibuja un borde sólido alrededor del control asociado en tiempo de diseño si el valor de la BorderStyle propiedad del control se establece en el NotSet campo o 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

Comentarios

Si la ErrorMessage propiedad o Text del control asociado que se deriva de la BaseValidator clase es una cadena vacía (""), o si la Display propiedad está establecida en el None campo, el GetDesignTimeHtml método establece la ErrorMessage propiedad en el identificador de control, que se incluye entre corchetes ([]) y establece la Display propiedad en el Static campo. A GetDesignTimeHtml continuación, llama al GetDesignTimeHtml método base para generar el marcado y restaura las propiedades del control a sus valores originales, si es necesario.

Se aplica a

Consulte también