次の方法で共有


LoginDesigner.GetDesignTimeHtml(DesignerRegionCollection) メソッド

定義

関連付けられたコントロールのデザイン時の表示に使用するマークアップを取得し、デザイナー領域のコレクションに追加します。

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

パラメーター

regions
DesignerRegionCollection

コントロールのデザイン時ビューの選択可能領域およびクリック可能領域の定義の追加先となる DesignerRegionCollection

戻り値

デザイン時に Login を表示するためのマークアップを格納している文字列。

次のコード例は、 クラスから継承されたクラスの メソッドをオーバーライド GetDesignTimeHtml して、デザイン時にコントロールから LoginDesigner 派生したコントロールの外観を変更する方法を Login 示しています。 次の使用例は、コントロールの プロパティが または None 値の場合BorderStyleに、コントロールの周囲に青い破線の境界線をNotSet描画して、その範囲を表示できるようにします。

// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
    // Make the control more visible in the designer.  If the border 
    // style is None or NotSet, change the border to a blue dashed line. 
    MyLogin myLoginCtl = (MyLogin)ViewControl;
    string markup = null;

    // Check if the border style should be changed.
    if (myLoginCtl.BorderStyle == BorderStyle.NotSet ||
        myLoginCtl.BorderStyle == BorderStyle.None)
    {
        BorderStyle oldBorderStyle = myLoginCtl.BorderStyle;
        Color oldBorderColor = myLoginCtl.BorderColor;

        // Set the design time properties and catch any exceptions.
        try
        {
            myLoginCtl.BorderStyle = BorderStyle.Dashed;
            myLoginCtl.BorderColor = Color.Blue;

            // Call the base method to generate the markup.
            markup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            markup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // It is not necessary to restore the border properties 
            // to their original values because the ViewControl 
            // was used to reference the associated control and the 
            // UsePreviewControl was not overridden.  

            // myLoginCtl.BorderStyle = oldBorderStyle;
            // myLoginCtl.BorderColor = oldBorderColor;
        }
    }
    else
    {
        // Call the base method to generate the markup.
        markup = base.GetDesignTimeHtml();
    }

    return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Public Overrides Function GetDesignTimeHtml() As String

    ' Make the control more visible in the designer.  If the border 
    ' style is None or NotSet, change the border to a blue dashed line. 
    Dim myLoginCtl As MyLogin = CType(ViewControl, MyLogin)
    Dim markup As String = Nothing

    ' Check if the border style should be changed.
    If (myLoginCtl.BorderStyle = BorderStyle.NotSet Or _
        myLoginCtl.BorderStyle = BorderStyle.None) Then

        Dim oldBorderStyle As BorderStyle = myLoginCtl.BorderStyle
        Dim oldBorderColor As Color = myLoginCtl.BorderColor

        ' Set the design time properties and catch any exceptions.
        Try
            myLoginCtl.BorderStyle = BorderStyle.Dashed
            myLoginCtl.BorderColor = Color.Blue

            ' Call the base method to generate the markup.
            markup = MyBase.GetDesignTimeHtml()

        Catch ex As Exception
            markup = GetErrorDesignTimeHtml(ex)

        Finally
            ' It is not necessary to restore the border properties 
            ' to their original values because the ViewControl 
            ' was used to reference the associated control and the 
            ' UsePreviewControl was not overridden.  

            ' myLoginCtl.BorderStyle = oldBorderStyle
            ' myLoginCtl.BorderColor = oldBorderColor
        End Try

    Else
        ' Call the base method to generate the markup.
        markup = MyBase.GetDesignTimeHtml()
    End If

    Return markup

End Function ' GetDesignTimeHtml

注釈

メソッドはGetDesignTimeHtml、関連付けられたLoginコントロールの プロパティの オブジェクトLayoutTemplateを作成し、 パラメーターによって参照されるオブジェクトにregions追加DesignerRegionCollectionします。EditableDesignerRegion メソッドは GetDesignTimeHtml 、基本メソッドを GetDesignTimeHtml 使用して、コントロールのデザイン時レンダリング用のマークアップを Login 生成します。

注意 (継承者)

メソッドをオーバーライドする GetDesignTimeHtml(DesignerRegionCollection) 場合は、最終的に複数の GetDesignTimeHtml() オーバーライド レベルを介して、コントロールまたはコントロールのコピーを呼び出してマークアップを生成するため、基本メソッドを呼び出 Login してください。

適用対象

こちらもご覧ください