Udostępnij za pośrednictwem


LoginStatusDesigner.GetDesignTimeHtml Metoda

Definicja

Pobiera znaczniki używane do renderowania skojarzonej kontrolki w czasie projektowania.

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

Zwraca

Ciąg zawierający znaczniki używane do renderowania w LoginStatus czasie projektowania.

Przykłady

Poniższy przykład kodu pokazuje, jak zastąpić GetDesignTimeHtml metodę w klasie dziedziczonej z LoginStatusDesigner klasy w celu zmiany wyglądu kontrolki pochodzącej LoginStatus z klasy w czasie projektowania. Przykład rysuje niebieskie, kreskowane obramowanie wokół kontrolki, aby jego zakres był bardziej widoczny, jeśli BorderStyle właściwość kontrolki jest wartością NotSet lub None .

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

Uwagi

LogoutText Jeśli właściwość lub LoginText (w zależności od tego, czy użytkownik jest zalogowany), to , pusty nullciąg (""), czy pojedyncza spacja (""), GetDesignTimeHtml metoda ustawia LogoutText właściwość lub LoginText odpowiednio dla ID właściwości, ujętej w nawiasy ("[ ]"). Następnie niezależnie od ustawienia LoginText metody lub LogoutTextGetDesignTimeHtml metoda wywołuje GetDesignTimeHtml metodę podstawową, aby wygenerować znaczniki renderowania kontrolki LoginStatus w czasie projektowania.

Uwagi dotyczące dziedziczenia

Jeśli zastąpisz GetDesignTimeHtml() metodę, pamiętaj, aby wywołać GetDesignTimeHtml() metodę podstawową, ponieważ w końcu przez kilka poziomów przesłonięcia wywołuje LoginStatus kontrolkę lub kopię kontrolki w celu wygenerowania znaczników.

Dotyczy

Zobacz też