共用方式為


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 物件。

傳回

如果控制項設計工具支援可編輯區域,則為該區域的保存內容;否則為空字串 ("")。

範例

下列程式代碼範例示範如何取得設計主機的參考,然後使用 參考來建立 物件,以建立 ControlParser 的 HTML 標記 region 及其內容。

// 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 方法以傳回指定區域的內容。

適用於

另請參閱