LiteralControl コンストラクター

定義

LiteralControl クラスの新しいインスタンスを初期化します。

オーバーロード

LiteralControl()

要求された ASP.NET ページに表示されるリテラル文字列を格納している LiteralControl クラスの新しいインスタンスを初期化します。

LiteralControl(String)

テキストを指定して、LiteralControl クラスの新しいインスタンスを初期化します。

LiteralControl()

要求された ASP.NET ページに表示されるリテラル文字列を格納している LiteralControl クラスの新しいインスタンスを初期化します。

public:
 LiteralControl();
public LiteralControl ();
Public Sub New ()

次のコード例では、 CustLiteralControlClassクラスを拡張する クラス を LiteralControl 作成します。 オブジェクトのテキストを指定しないコンストラクターを使用して、 という名前 myLiteralControlClass1 のクラスのインスタンスを LiteralControl 作成します。 オブジェクトが作成されると、 プロパティを Text 使用して、オブジェクトに含まれるテキストが設定されます。

CustomLiteralControlClass myLiteralControlClass1= 
               new CustomLiteralControlClass();
myLiteralControlClass1.Text="This Control demonstrates the constructor1";
Dim myLiteralControlClass1 as CustomLiteralControlClass = _
new CustomLiteralControlClass()
myLiteralControlClass1.Text="This Control demonstrates the constructor1"

適用対象

LiteralControl(String)

テキストを指定して、LiteralControl クラスの新しいインスタンスを初期化します。

public:
 LiteralControl(System::String ^ text);
public LiteralControl (string text);
new System.Web.UI.LiteralControl : string -> System.Web.UI.LiteralControl
Public Sub New (text As String)

パラメーター

text
String

要求された Web ページに表示されるテキスト。

次のコード例では、 コンストラクターを使用して クラス LiteralControl の 2 つのインスタンスを LiteralControl 作成します。 2 つのインスタンスは、H3 HTML 要素の開始タグと終了タグをレンダリングし、H3 タグ内に表示するテキストを含めます。

// Add two LiteralControls that render HTML H3 elements and text.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
protected override void CreateChildControls() {

    this.Controls.Add(new LiteralControl("<h3>Value: "));

    TextBox box = new TextBox();
    box.Text = "0";
    this.Controls.Add(box);

    this.Controls.Add(new LiteralControl("</h3>"));
}
' Add two LiteralControls that render HTML H3 elements and text.
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub CreateChildControls()

    Me.Controls.Add(New LiteralControl("<h3>Value: "))

    Dim Box As New TextBox
    Box.Text = "0"
    Me.Controls.Add(box)

    Me.Controls.Add(New LiteralControl("</h3>"))
End Sub

こちらもご覧ください

適用対象