Share via


BaseValidatorDesigner.GetDesignTimeHtml Methode

Definition

Ruft das Markup ab, das zum Rendern des zugeordneten Steuerelements zur Entwurfszeit verwendet wird.

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

Gibt zurück

Eine Zeichenfolge, die das Markup enthält, mit dem das BaseValidator zur Entwurfszeit gerendert wird.

Beispiele

Das folgende Codebeispiel zeigt, wie die Methode überschrieben wird, die GetDesignTimeHtml zur Entwurfszeit einen festen Rahmen um das zugeordnete Steuerelement zeichnet, wenn der Wert der BorderStyle Eigenschaft des Steuerelements auf das NotSet Feld oder None festgelegt ist.

// 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

Hinweise

Wenn die ErrorMessageText oder -Eigenschaft des zugeordneten Steuerelements, das von der BaseValidator -Klasse abgeleitet wird, eine leere Zeichenfolge ("") ist oder die Display -Eigenschaft auf das None Feld festgelegt ist, legt die GetDesignTimeHtml -Methode die ErrorMessage -Eigenschaft auf die Steuerelement-ID fest, die in Klammern ([]) eingeschlossen ist, und legt die Display -Eigenschaft auf das Static Feld fest. Ruft GetDesignTimeHtml dann die GetDesignTimeHtml Basismethode auf, um das Markup zu generieren, und stellt die Steuerelementeigenschaften bei Bedarf auf ihre ursprünglichen Werte zurück.

Gilt für:

Weitere Informationen