ControlDesigner.GetDesignTimeHtml メソッド

定義

デザイン時にコントロールを表すために使用される HTML マークアップを取得します。

オーバーロード

名前 説明
GetDesignTimeHtml(DesignerRegionCollection)

コントロールを表示する HTML マークアップを取得し、コレクションに現在のコントロール デザイナー領域を設定します。

GetDesignTimeHtml()

デザイン時にコントロールを表すために使用される HTML マークアップを取得します。

GetDesignTimeHtml(DesignerRegionCollection)

コントロールを表示する HTML マークアップを取得し、コレクションに現在のコントロール デザイナー領域を設定します。

public:
 virtual System::String ^ GetDesignTimeHtml(System::Web::UI::Design::DesignerRegionCollection ^ regions);
public virtual string GetDesignTimeHtml(System.Web.UI.Design.DesignerRegionCollection regions);
abstract member GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
override this.GetDesignTimeHtml : System.Web.UI.Design.DesignerRegionCollection -> string
Public Overridable Function GetDesignTimeHtml (regions As DesignerRegionCollection) As String

パラメーター

regions
DesignerRegionCollection

関連付けられたコントロールのコントロール デザイナー領域のコレクション。

返品

すべてのコントロール デザイナー領域を含む、関連付けられたコントロールのデザイン時 HTML マークアップ。

次のコード例は、 DesignerRegionCollection コレクションを使用して HTML マークアップを作成する方法を示しています。

// Create the regions and design-time markup. Called by the designer host.
public override String GetDesignTimeHtml(DesignerRegionCollection regions) {
    // Create 3 regions: 2 clickable headers and an editable row
    regions.Add(new DesignerRegion(this, "Header0"));
    regions.Add(new DesignerRegion(this, "Header1"));

    // Create an editable region and add it to the regions
    EditableDesignerRegion editableRegion = 
        new EditableDesignerRegion(this, 
            "Content" + myControl.CurrentView, false);
    regions.Add(editableRegion);

    // Set the highlight for the selected region
    regions[myControl.CurrentView].Highlight = true;

    // Use the base class to render the markup
    return base.GetDesignTimeHtml();
}
' Create the regions and design-time markup. Called by the designer host.
Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String
    ' Create 3 regions: 2 clickable headers and an editable row
    regions.Add(New DesignerRegion(Me, "Header0"))
    regions.Add(New DesignerRegion(Me, "Header1"))

    ' Create an editable region and add it to the regions
    Dim editableRegion As EditableDesignerRegion = _
        New EditableDesignerRegion(Me, _
            "Content" & myControl.CurrentView, False)
    regions.Add(editableRegion)

    ' Set the highlight for the selected region
    regions(myControl.CurrentView).Highlight = True

    ' Use the base class to render the markup
    Return MyBase.GetDesignTimeHtml()
End Function

注釈

デザイン ホストは、 GetDesignTimeHtml メソッドを呼び出して、デザイン時の HTML マークアップとコントロール デザイナー領域の現在のリストを取得します。 DesignerRegionCollection を使用すると、デザイン ホストは編集可能なコントロール デザイナー領域ごとにマークアップを要求できます。

GetDesignTimeHtml メソッドは、GetDesignTimeHtml メソッドを呼び出す前に領域のコンテンツを処理する必要がある、GridViewDesigner クラスなどの派生コントロール デザイナーに対して提供されます。

こちらもご覧ください

適用対象

GetDesignTimeHtml()

デザイン時にコントロールを表すために使用される HTML マークアップを取得します。

public:
 virtual System::String ^ GetDesignTimeHtml();
public virtual string GetDesignTimeHtml();
abstract member GetDesignTimeHtml : unit -> string
override this.GetDesignTimeHtml : unit -> string
Public Overridable Function GetDesignTimeHtml () As String

返品

デザイン時にコントロールを表すために使用される HTML マークアップ。

次のコード例では、カスタム コントロール デザイナーで GetDesignTimeHtml メソッドをオーバーライドする方法を示します。 関連付けられたコントロールの Text プロパティが空の場合、 GetDesignTimeHtml メソッドは GetEmptyDesignTimeHtml メソッドを呼び出します。 それ以外の場合、 GetDesignTimeHtml メソッドは Hyperlink コントロールを作成してレンダリングします。

public override string GetDesignTimeHtml()
{
    if (simpleControl.Text.Length > 0)
    {
        string spec = "<a href='{0}.aspx'>{0}</a>";
        return String.Format(spec, simpleControl.Text);
    }
    else
    {
        return GetEmptyDesignTimeHtml();
    }
}
Public Overrides Function GetDesignTimeHtml() As String
   ' Component is the instance of the component or control that
   ' this designer object is associated with. This property is 
   ' inherited from System.ComponentModel.ComponentDesigner.
   simpleControl = CType(Component, Simple)
   
   If simpleControl.Text.Length > 0 Then
      Dim sw As New StringWriter()
      Dim tw As New HtmlTextWriter(sw)
      
      Dim placeholderLink As New HyperLink()
      
      ' Put simpleControl.Text into the link's Text.
      placeholderLink.Text = simpleControl.Text
      placeholderLink.NavigateUrl = simpleControl.Text
      placeholderLink.RenderControl(tw)
      
      Return sw.ToString()
   Else
      Return GetEmptyDesignTimeHtml()
   End If
End Function

注意 (継承者)

カスタム コンテナー コントロールを作成する場合は、 Visible プロパティが true に設定されているか、 falseに設定されているかに関係なく、コントロールとすべての子コントロールをデザイン時にレンダリングするようにしてください。

こちらもご覧ください

適用対象