DataBoundLiteralControl クラス
アセンブリ: System.Web (system.web.dll 内)



DataBoundLiteralControl オブジェクトを取得するクラスを作成し、このオブジェクトの Text プロパティを表示する方法を次のコード例に示します。
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

System.Web.UI.Control
System.Web.UI.DataBoundLiteralControl


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataBoundLiteralControl クラスのページへのリンク