ControlDesigner.GetEditableDesignerRegionContent Método

Definição

Devolve o conteúdo para uma região editável da vista em tempo de design do controlo 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 EditableDesignerRegion objetivo para obter conteúdo.

Devoluções

O conteúdo persistente para a região, se o designer de controlos suportar regiões editáveis; caso contrário, uma cadeia vazia ("").

Exemplos

O exemplo de código seguinte mostra como obter uma referência para o host de design e depois usar a referência para criar um ControlParser objeto que crie a marcação HTML para region e o 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

Observações

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

As classes derivadas da ControlDesigner classe podem suportar edição baseada em regiões na superfície de design e sobrescrever o GetEditableDesignerRegionContent método para devolver o conteúdo para uma região especificada.

Aplica-se a

Ver também