DataBoundLiteralControl.Text プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataBoundLiteralControl.Text プロパティの意味・解説 

DataBoundLiteralControl.Text プロパティ

DataBoundLiteralControl オブジェクトテキストの内容取得します

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

解説解説

DataBoundLiteralControl クラスは、Text プロパティの値をビューステート永続化ます。

使用例使用例

カスタム コントロール作成し、このコントロール.aspx ファイル内から使用してDataBoundLiteralControl オブジェクトテキスト表示する方法次のコード例示します。このカスタム コントロールDataBoundLiteralControl オブジェクト取得しRender メソッド使用してテキスト プロパティ出力します

Imports System
Imports System.Web
Imports System.Web.UI


Namespace Samples.AspNet.VB.Controls 
   
   Public Class MyControlVB
      Inherits Control     

      <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
      Protected Overrides Sub
 Render(Output As HtmlTextWriter)
         ' Checks if a DataBoundLiteralControl object is present.
         If HasControls() And TypeOf
 Controls(0) Is DataBoundLiteralControl Then
            

            ' Obtains the DataBoundLiteralControl instance.
            Dim boundLiteralControl As DataBoundLiteralControl
 = CType(Controls(0), DataBoundLiteralControl)
            ' Retrieves the text in the boundLiteralControl object.
            Dim text As String
 = boundLiteralControl.Text
            output.Write(("<h4>Your Message: "
 + text + "</h4>"))
         End If 
      End Sub 'Render  

   End Class 'MyControl
End Namespace 'MyUserControl
using System;
using System.Web;
using System.Web.UI;

namespace Samples.AspNet.CS.Controls 
{

   public class MyControl : Control 
   {
 
    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name="FullTrust")] 
    protected override void Render(HtmlTextWriter
 output) 
    {
      // Checks if a DataBoundLiteralControl object is present.
      if ( (HasControls()) && (Controls[0] is DataBoundLiteralControl)
 ) 
      {
        // Obtains the DataBoundLiteralControl instance.
        DataBoundLiteralControl boundLiteralControl = (DataBoundLiteralControl)Controls[0];
        // Retrieves the text in the boundLiteralControl object.
        String text = boundLiteralControl.Text;
        output.Write("<h4>Your Message: " +text+"</h4>");

      }
    }
   }    
}

/*File name: myDataBoundLiteralControl.jsl */
import System.*;
import System.Web.*;
import System.Web.UI.*;

public class MyControl extends Control
{
    protected void Render(HtmlTextWriter output)
    {
        // Checks if a DataBoundLiteralControl object is present.
        if (HasControls() && get_Controls().get_Item(0)
            instanceof DataBoundLiteralControl) {
            // Obtains the DataBoundLiteralControl instance.
            DataBoundLiteralControl boundLiteralControl =
                (DataBoundLiteralControl)get_Controls().get_Item(0);
            // Retrieves the text in the boundLiteralControl object.
            String text = boundLiteralControl.get_Text();
            output.Write("<h4>Your Message: " + text + "</h4>");
        }
    } //Render 
} //MyControl

Visual Basic コンパイラ (vbc.exe) または C# コンパイラ (csc.exe) を使用してコントロールコンパイルできます結果として得られ.dll ファイルは、次のコード例に示すように、Web プロジェクトBin ディレクトリ配置する必要があります

vbc /r:System.dll /r:System.Web.dll /t:library /out:myWebAppPath/bin/vb_myDataBoundLiteralControl.dll
 myDataBoundLiteralControl.vb
csc /t:library /out:myWebAppPath/bin/cs_myDataBoundLiteralControl.dll myDataBoundLiteralControl.cs

カスタム コントロール作成し.aspx ファイル登録して使用する方法次のコード例示します

<%@ Page Language="VB" %>
<%@ Register TagPrefix="MyControlSample" Namespace="Samples.AspNet.VB.Controls"
 %>
<html>
  <head>
    <script language="VB" runat="server">
        Sub Page_Load(ByVal Sender As
 Object, ByVal e As EventArgs)
            Page.DataBind()
        End Sub
    </script>
  </head>
  <body>
  <h3>
      DataBoundLiteralControl Example
  </h3>
  <form method="post" runat="server"
 ID="Form1">
    <asp:Label id="Label1" Text="This is
 a string retrieved from 'DataBoundLiteralControl'"
 Runat="server" Visible="False"></asp:Label>
    <MyControlSample:MyControlVB id="MyControl"
 runat="server">
        <%# Label1.Text %>
    </MyControlSample:MyControlVB>
  </form>
  </body>
</html>
<%@ Page Language="C#" %>
<%@ Register TagPrefix="MyControlSample" Namespace="Samples.AspNet.CS.Controls"
 %>
<html>
  <head>
    <script language="C#" runat="server">
      void Page_Load(Object Sender, EventArgs e)
      {
        Page.DataBind();
      }
    </script>
  </head>
  <body>
  <h3>
    DataBoundLiteralControl Example
  </h3>
  <form method="post" runat="server" ID="Form1">
    <asp:Label id="Label1" Text="This is a string
 retrieved from 'DataBoundLiteralControl'" Runat="server" Visible="False"></asp:Label>
    <MyControlSample:MyControl id="MyControl" runat="server">
        <%# Label1.Text %>
    </MyControlSample:MyControl>
  </form>
  </body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataBoundLiteralControl クラス
DataBoundLiteralControl メンバ
System.Web.UI 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataBoundLiteralControl.Text プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataBoundLiteralControl.Text プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataBoundLiteralControl.Text プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「DataBoundLiteralControl.Text プロパティ」の関連用語

DataBoundLiteralControl.Text プロパティのお隣キーワード
検索ランキング

   

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



DataBoundLiteralControl.Text プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS