LoginStatusDesigner.GetDesignTimeHtml Methode

Definitie

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 LoginStatus ontwerptijd weer te geven.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u de GetDesignTimeHtml methode in een klasse overschrijft die wordt overgenomen van de LoginStatusDesigner klasse om het uiterlijk van een besturingselement te wijzigen dat tijdens het ontwerp is afgeleid van de LoginStatus klasse. In het voorbeeld wordt een blauwe, stippelrand rond het besturingselement tekend om de omvang ervan beter zichtbaar te maken als de BorderStyle eigenschap van het besturingselement de NotSet of None waarde is.

// 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. 
    MyLoginStatus myLoginStatusCtl = (MyLoginStatus)ViewControl;
    string markup = null;

    // Check if the border style should be changed.
    if (myLoginStatusCtl.BorderStyle == BorderStyle.NotSet ||
        myLoginStatusCtl.BorderStyle == BorderStyle.None)
    {
        BorderStyle oldBorderStyle = myLoginStatusCtl.BorderStyle;
        Color oldBorderColor = myLoginStatusCtl.BorderColor;

        // Set the design time properties and catch any exceptions.
        try
        {
            myLoginStatusCtl.BorderStyle = BorderStyle.Dashed;
            myLoginStatusCtl.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 myLoginStatusCtl As MyLoginStatus = _
        CType(ViewControl, MyLoginStatus)
    Dim markup As String = Nothing

    ' Check if the border style should be changed.
    If (myLoginStatusCtl.BorderStyle = BorderStyle.NotSet Or _
        myLoginStatusCtl.BorderStyle = BorderStyle.None) Then

        Dim oldBorderStyle As BorderStyle = myLoginStatusCtl.BorderStyle
        Dim oldBorderColor As Color = myLoginStatusCtl.BorderColor

        ' Set the design time properties and catch any exceptions.
        Try
            myLoginStatusCtl.BorderStyle = BorderStyle.Dashed
            myLoginStatusCtl.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

Opmerkingen

Als de LogoutText of LoginText eigenschap (afhankelijk van of de gebruiker is aangemeld), een nulllege tekenreeks ("") is, of één spatie (""), stelt de GetDesignTimeHtml methode de LogoutText of LoginText eigenschap, indien van toepassing, in op de ID eigenschap tussen vierkante haken ("[ ]"). Vervolgens roept de LoginText methode, ongeacht de instelling van de LogoutText ofGetDesignTimeHtml, de basismethode aan GetDesignTimeHtml om de opmaak te genereren voor de ontwerptijdweergave van het LoginStatus besturingselement.

Notities voor overnemers

Als u de GetDesignTimeHtml() methode overschrijft, moet u de GetDesignTimeHtml() basismethode aanroepen, omdat deze uiteindelijk, via verschillende onderdrukkingsniveaus, het LoginStatus besturingselement of een kopie van het besturingselement aanroept om de opmaak te genereren.

Van toepassing op

Zie ook