Partager via


LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) Méthode

Définition

Obtient le balisage utilisé pour afficher le contrôle associé au moment de la conception et remplit une collection de zones du concepteur.

public:
 override System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public override string GetDesignTimeHtml (System.Web.UI.Design.DesignerRegionCollection regions);
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overrides Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String

Paramètres

regions
DesignerRegionCollection

DesignerRegionCollection auquel sont ajoutées des définitions des régions pouvant être sélectionnées et sur lesquelles cliquer dans la vue au moment de la conception du contrôle.

Retours

Chaîne qui contient le balisage utilisé pour rendre Login au moment du design.

Exemples

L’exemple de code suivant montre comment remplacer la GetDesignTimeHtml méthode dans une classe héritée de la LoginDesigner classe pour modifier l’apparence d’un contrôle dérivé du contrôle au moment de la Login conception. L’exemple dessine une bordure bleue et pointillée autour du contrôle pour rendre son étendue plus visible, si la BorderStyle propriété du contrôle est la NotSet valeur ou 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. 
    MyLogin myLoginCtl = (MyLogin)ViewControl;
    string markup = null;

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

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

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

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

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

Remarques

La GetDesignTimeHtml méthode crée un EditableDesignerRegion objet pour la LayoutTemplate propriété du contrôle associé Login et l’ajoute à l’objet DesignerRegionCollection référencé par le regions paramètre . La GetDesignTimeHtml méthode utilise la GetDesignTimeHtml méthode de base pour générer le balisage pour le rendu au moment de la conception du Login contrôle.

Notes pour les héritiers

Si vous remplacez la GetDesignTimeHtml(DesignerRegionCollection) méthode, veillez à appeler la GetDesignTimeHtml() méthode de base, car elle appelle éventuellement, par le biais de plusieurs niveaux de remplacement, des appels sur le Login contrôle ou une copie du contrôle pour générer le balisage.

S’applique à

Voir aussi