LiteralControl クラスとは? わかりやすく解説

LiteralControl クラス

HTML 要素テキスト、およびサーバーでの処理を必要としない ASP.NET ページその他の文字列を表します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class LiteralControl
    Inherits Control
    Implements ITextControl
Dim instance As LiteralControl
public class LiteralControl : Control, ITextControl
public ref class LiteralControl : public
 Control, ITextControl
public class LiteralControl extends Control
 implements ITextControl
public class LiteralControl extends
 Control implements ITextControl
解説解説

ASP.NET は、すべての HTML 要素およびサーバー側の処理を必要とせずに読み取ることができるテキストを、このクラスインスタンスコンパイルます。たとえば、runat="server"属性と値のペア開始タグ含んでいない HTML 要素は、LiteralControl オブジェクトコンパイルされますLiteralControl オブジェクトビューステート保持しないため、LiteralControl オブジェクト内容要求ごとに再作成する必要があります

リテラル コントロールは、テキスト ホルダとして動作します。つまり、リテラル コントロールかテキスト抽出し、親サーバー コントロールの ControlCollection コレクションから親の Controls プロパティ通じてリテラル コントロール削除できます。したがってLiteralControl クラスから派生したカスタム コントロール開発する場合は、コントロールが LiteralControl.Render メソッド呼び出し使用してプリプロセス手順を行うのではなくコントロール自体必要なプリプロセス手順実行するようにします。一般的にこのようにすると、Web アプリケーション応答時間短縮できます

ControlCollection.Add メソッドまたは ControlCollection.Remove メソッド使用すると、ページ コントロールまたはサーバー コントロールからリテラル コントロールプログラムによって追加または削除できます

使用例使用例

Control.CreateChildControls メソッドオーバーライドするときに、オーバーロードされた LiteralControl コンストラクタ使用する方法次のコード例示します。このコードでは、2 つ新しLiteralControl オブジェクトTextBox Web サーバー コントロール現在のサーバー コントロールControl.Controls プロパティ追加します

' 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
// 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.
protected void CreateChildControls()
{
    this.get_Controls().Add(new LiteralControl("<h3>Value:
 "));

    TextBox box = new TextBox();
    box.set_Text("0");
    this.get_Controls().Add(box);

    this.get_Controls().Add(new LiteralControl("</h3>"));
} //CreateChildControls
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
    System.Web.UI.LiteralControl
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「LiteralControl クラス」の関連用語

LiteralControl クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



LiteralControl クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS