ControlDesigner.GetEditableDesignerRegionContent メソッド

定義

関連付けられたコントロールのデザイン時ビューの編集可能領域の内容を返します。

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

パラメーター

region
EditableDesignerRegion

コンテンツを取得する EditableDesignerRegion オブジェクト。

戻り値

String

コントロール デザイナーが編集可能領域をサポートする場合は領域の永続化された内容。それ以外の場合は空の文字列 ("")。

次のコード例は、デザイン ホストへの参照を取得し、その参照を使用して、HTML マークアップregionとその内容を作成するオブジェクトを作成ControlParserする方法を示しています。

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

注釈

このメソッドの既定の GetEditableDesignerRegionContent 実装では、空の文字列 ("") が返されます。

クラスから ControlDesigner 派生するクラスは、デザイン サーフェイスでのリージョンベースの編集をサポートし、指定したリージョンの GetEditableDesignerRegionContent コンテンツを返すメソッドをオーバーライドできます。

適用対象

こちらもご覧ください