ControlDesigner.GetEditableDesignerRegionContent Metoda

Definicja

Zwraca zawartość dla edytowalnego regionu widoku czasu projektowania skojarzonej kontrolki.

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

Parametry

region
EditableDesignerRegion

Obiekt do pobierania EditableDesignerRegion zawartości.

Zwraca

String

Utrwalone treści dla regionu, jeśli projektant kontrolek obsługuje edytowalne regiony; w przeciwnym razie pusty ciąg ("").

Przykłady

Poniższy przykład kodu pokazuje, jak uzyskać odwołanie do hosta projektu, a następnie użyć odwołania do utworzenia obiektu, który tworzy ControlParser znaczniki HTML dla region i jego zawartości.

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

Uwagi

Domyślna implementacja GetEditableDesignerRegionContent metody zwraca pusty ciąg ("").

Klasy pochodne z ControlDesigner klasy mogą obsługiwać edytowanie oparte na regionie na powierzchni projektowej i przesłaniać GetEditableDesignerRegionContent metodę w celu zwrócenia zawartości dla określonego regionu.

Dotyczy

Zobacz też