Share via


ControlDesigner.GetEditableDesignerRegionContent Método

Definição

Retorna o conteúdo de uma região editável do modo de exibição de tempo de design do controle associado.

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

Parâmetros

region
EditableDesignerRegion

O objeto EditableDesignerRegion para o qual o conteúdo deve ser obtido.

Retornos

String

O conteúdo persistente da região se o designer de controle tiver suporte para regiões editáveis. Caso contrário, uma cadeia de caracteres vazia ("").

Exemplos

O exemplo de código a seguir mostra como obter uma referência ao host de design e, em seguida, usar a referência para criar um ControlParser objeto que cria a marcação HTML para region e seu conteúdo.

// Get the content string for the selected region. Called by the designer host?
public override string GetEditableDesignerRegionContent(EditableDesignerRegion region) 
{
    // Get a reference to the designer host
    IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
    if (host != null)
    {
        ITemplate template = myControl.View1;
        if (region.Name == "Content1")
            template = myControl.View2;

        // Persist the template in the design host
        if (template != null)
            return ControlPersister.PersistTemplate(template, host);
    }

    return String.Empty;
}
' Get the content string for the selected region. Called by the designer host?
Public Overrides Function GetEditableDesignerRegionContent(ByVal region As EditableDesignerRegion) As String
    ' Get a reference to the designer host
    Dim host As IDesignerHost = CType(Component.Site.GetService(GetType(IDesignerHost)), IDesignerHost)

    If Not IsNothing(host) Then
        Dim template As ITemplate = myControl.View1
        If region.Name = "Content1" Then
            template = myControl.View2
        End If

        ' Persist the template in the design host
        If Not IsNothing(template) Then
            Return ControlPersister.PersistTemplate(template, host)
        End If
    End If

    Return String.Empty
End Function

Comentários

A implementação padrão do GetEditableDesignerRegionContent método retorna uma cadeia de caracteres vazia ("").

Classes derivadas da classe podem dar suporte à ControlDesigner edição baseada em região na superfície de design e substituir o GetEditableDesignerRegionContent método para retornar o conteúdo de uma região especificada.

Aplica-se a

Confira também