LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) Método

Definição

Obtém a marcação que é usada para renderizar o controle associado em tempo de design e preenche uma coleção de regiões de designer.Gets the markup that is used to render the associated control at design time and populates a collection of designer regions.

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

Parâmetros

regions
DesignerRegionCollection

Um DesignerRegionCollection ao qual as definições das regiões selecionáveis e clicáveis na exibição de tempo de design do controle são adicionadas.A DesignerRegionCollection to which definitions of the selectable and clickable regions in the design-time view of the control are added.

Retornos

String

Uma cadeia de caracteres que contém a marcação usada para renderizar o Login em tempo de design.A string containing the markup used to render the Login at design time.

Exemplos

O exemplo de código a seguir mostra como substituir o GetDesignTimeHtml método em uma classe que é herdada da LoginDesigner classe para alterar a aparência de um controle que é derivado do Login controle em tempo de design.The following code example shows how to override the GetDesignTimeHtml method in a class that is inherited from the LoginDesigner class to change the appearance of a control that is derived from the Login control at design time. O exemplo desenha uma borda azul tracejada em torno do controle para tornar sua extensão mais visível, se a BorderStyle Propriedade do controle for o NotSet None valor ou.The example draws a blue, dashed border around the control to make its extent more visible, if the BorderStyle property of the control is the NotSet or None value.

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

Comentários

O GetDesignTimeHtml método cria um EditableDesignerRegion objeto para a LayoutTemplate Propriedade do controle associado Login e o adiciona ao DesignerRegionCollection objeto que é referenciado pelo regions parâmetro.The GetDesignTimeHtml method creates an EditableDesignerRegion object for the LayoutTemplate property of the associated Login control and adds it to the DesignerRegionCollection object that is referenced by the regions parameter. O GetDesignTimeHtml método usa o GetDesignTimeHtml método base para gerar a marcação para a renderização de tempo de design do Login controle.The GetDesignTimeHtml method uses the GetDesignTimeHtml base method to generate the markup for the design-time rendering of the Login control.

Notas aos Herdeiros

Se você substituir o GetDesignTimeHtml(DesignerRegionCollection) método, certifique-se de chamar o GetDesignTimeHtml() método base porque eventualmente, por meio de vários níveis de substituição, chamadas no Login controle ou uma cópia do controle para gerar a marcação.If you override the GetDesignTimeHtml(DesignerRegionCollection) method, be sure to call the GetDesignTimeHtml() base method because it eventually, through several override levels, calls on the Login control or a copy of the control to generate the markup.

Aplica-se a

Confira também