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 マークアップ。

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

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

こちらもご覧ください

適用対象

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

注意 (継承者)

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

こちらもご覧ください

適用対象