ControlDesigner.GetEditableDesignerRegionContent Metodo

Definizione

Restituisce il contenuto per un'area modificabile della visualizzazione Design-Time del controllo associato.

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

Parametri

region
EditableDesignerRegion

Oggetto EditableDesignerRegion per il quale ottenere il contenuto.

Restituisce

String

Contenuto persistente per l'area, se la finestra di progettazione supporta le aree modificabili. In caso contrario, una stringa vuota ("").

Esempio

Nell'esempio di codice seguente viene illustrato come ottenere un riferimento all'host di progettazione e quindi usare il riferimento per creare un ControlParser oggetto che crea il markup HTML per region e il relativo contenuto.

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

Commenti

L'implementazione predefinita del GetEditableDesignerRegionContent metodo restituisce una stringa vuota ("").

Le classi derivate dalla classe possono supportare la ControlDesigner modifica basata sull'area nell'area di progettazione ed eseguire l'override del GetEditableDesignerRegionContent metodo per restituire il contenuto per un'area specificata.

Si applica a

Vedi anche