ControlDesigner.GetEditableDesignerRegionContent Méthode

Définition

Retourne le contenu d'une région modifiable de la vue au moment de la conception du contrôle associé.

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

Paramètres

region
EditableDesignerRegion

Objet EditableDesignerRegion pour lequel obtenir le contenu.

Retours

String

Contenu rendu persistant pour la zone, si le concepteur de contrôles prend en charge les zones modifiables ; sinon, une chaîne vide ("").

Exemples

L’exemple de code suivant montre comment obtenir une référence à l’hôte de conception, puis utiliser la référence pour créer un ControlParser objet qui crée le balisage HTML pour region et son contenu.

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

Remarques

L’implémentation par défaut de la GetEditableDesignerRegionContent méthode retourne une chaîne vide («  »).

Les classes dérivées de la ControlDesigner classe peuvent prendre en charge la modification basée sur la région sur l’aire de conception et remplacer la GetEditableDesignerRegionContent méthode pour renvoyer le contenu d’une région spécifiée.

S’applique à

Voir aussi