ControlDesigner.GetEditableDesignerRegionContent 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳可編輯區域中可編輯的相關控制項。
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 該方法以回傳指定區域的內容。