HiddenFieldDesigner.GetDesignTimeHtml 方法

定义

获取用于在设计时呈现关联控件的标记。

public:
 override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String

返回

String

一个字符串,其中包含用于在设计时呈现 HiddenField 的标记。

示例

下面的代码示例演示如何重写 GetDesignTimeHtmlHiddenFieldDesigner 类继承的类中的方法,以在设计时更改控件的外观 HiddenField 。 重写 GetDesignTimeHtml 将生成一个占位符,该占位符中包含 Value 该占位符中的属性以及控件类名称和 ID 属性。

// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
    // Get a reference to the control or a copy of the control.
    MyHiddenField myHF = (MyHiddenField)ViewControl;

    // Create a placeholder that displays the control value.
    string markup = CreatePlaceHolderDesignTimeHtml(
         "Value: \"" + myHF.Value.ToString() + "\"" );

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

    ' Get a reference to the control or a copy of the control.
    Dim myHF As MyHiddenField = CType(ViewControl, MyHiddenField)

    Dim markup As String = _
        CreatePlaceHolderDesignTimeHtml( _
            "Value: """ & myHF.Value.ToString() & """" )

    Return markup

End Function ' GetDesignTimeHtml

注解

该方法 GetDesignTimeHtml 为包含控件类名称和属性的 ID 占位符生成标记。

适用于

另请参阅