ControlDesigner.GetDesignTimeHtml Método

Definición

Recupera el formato HTML que se usa para representar el control en tiempo de diseño.

Sobrecargas

GetDesignTimeHtml(DesignerRegionCollection)

Recupera el formato HTML para mostrar el control y rellena la colección con las regiones actuales del diseñador de controles.

GetDesignTimeHtml()

Recupera el formato HTML que se usa para representar el control en tiempo de diseño.

GetDesignTimeHtml(DesignerRegionCollection)

Recupera el formato HTML para mostrar el control y rellena la colección con las regiones actuales del diseñador de controles.

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

Parámetros

regions
DesignerRegionCollection

Colección de regiones del diseñador de controles para el control asociado.

Devoluciones

String

Formato HTML en tiempo de diseño para el control asociado, incluidas todas las regiones del diseñador de controles.

Ejemplos

En el ejemplo de código siguiente se muestra cómo crear marcado HTML mediante la DesignerRegionCollection colección .

// Create the regions and design-time markup. Called by the designer host.
public override String GetDesignTimeHtml(DesignerRegionCollection regions) {
    // Create 3 regions: 2 clickable headers and an editable row
    regions.Add(new DesignerRegion(this, "Header0"));
    regions.Add(new DesignerRegion(this, "Header1"));

    // Create an editable region and add it to the regions
    EditableDesignerRegion editableRegion = 
        new EditableDesignerRegion(this, 
            "Content" + myControl.CurrentView, false);
    regions.Add(editableRegion);

    // Set the highlight for the selected region
    regions[myControl.CurrentView].Highlight = true;

    // Use the base class to render the markup
    return base.GetDesignTimeHtml();
}
' Create the regions and design-time markup. Called by the designer host.
Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String
    ' Create 3 regions: 2 clickable headers and an editable row
    regions.Add(New DesignerRegion(Me, "Header0"))
    regions.Add(New DesignerRegion(Me, "Header1"))

    ' Create an editable region and add it to the regions
    Dim editableRegion As EditableDesignerRegion = _
        New EditableDesignerRegion(Me, _
            "Content" & myControl.CurrentView, False)
    regions.Add(editableRegion)

    ' Set the highlight for the selected region
    regions(myControl.CurrentView).Highlight = True

    ' Use the base class to render the markup
    Return MyBase.GetDesignTimeHtml()
End Function

Comentarios

El host de diseño llama al GetDesignTimeHtml método para obtener el marcado HTML en tiempo de diseño y la lista actual de regiones del diseñador de controles. Con DesignerRegionCollection, el host de diseño puede solicitar el marcado para cada región del diseñador de controles editable.

El GetDesignTimeHtml método se proporciona para un diseñador de controles derivados, como la GridViewDesigner clase , que debe procesar el contenido de la región antes de llamar al GetDesignTimeHtml método .

Consulte también

Se aplica a

GetDesignTimeHtml()

Recupera el formato HTML que se usa para representar el control en tiempo de diseño.

public:
 virtual System::String ^ GetDesignTimeHtml();
public virtual string GetDesignTimeHtml ();
abstract member GetDesignTimeHtml : unit -> string
override this.GetDesignTimeHtml : unit -> string
Public Overridable Function GetDesignTimeHtml () As String

Devoluciones

String

Marcado HTML que se usa para representar el control en tiempo de diseño.

Ejemplos

En el ejemplo de código siguiente se muestra cómo invalidar el GetDesignTimeHtml método en un diseñador de controles personalizados. Si la propiedad Text del control asociado está vacía, el GetDesignTimeHtml método llama al GetEmptyDesignTimeHtml método . De lo contrario, el GetDesignTimeHtml método crea y representa un control Hyperlink.

public override string GetDesignTimeHtml()
{
    if (simpleControl.Text.Length > 0)
    {
        string spec = "<a href='{0}.aspx'>{0}</a>";
        return String.Format(spec, simpleControl.Text);
    }
    else
    {
        return GetEmptyDesignTimeHtml();
    }
}
Public Overrides Function GetDesignTimeHtml() As String
   ' Component is the instance of the component or control that
   ' this designer object is associated with. This property is 
   ' inherited from System.ComponentModel.ComponentDesigner.
   simpleControl = CType(Component, Simple)
   
   If simpleControl.Text.Length > 0 Then
      Dim sw As New StringWriter()
      Dim tw As New HtmlTextWriter(sw)
      
      Dim placeholderLink As New HyperLink()
      
      ' Put simpleControl.Text into the link's Text.
      placeholderLink.Text = simpleControl.Text
      placeholderLink.NavigateUrl = simpleControl.Text
      placeholderLink.RenderControl(tw)
      
      Return sw.ToString()
   Else
      Return GetEmptyDesignTimeHtml()
   End If
End Function

Notas a los desarrolladores de herederos

Si va a crear un control de contenedor personalizado, asegúrese de representar el control y todos los controles secundarios en tiempo de diseño, independientemente de si la Visible propiedad está establecida true en o false.

Consulte también

Se aplica a