保留資料繫結運算式和靜態常值文字。這個類別無法被繼承。
命名空間: System.Web.UI
組件: System.Web (在 system.web.dll 中)
Public NotInheritable Class DataBoundLiteralControl
Inherits Control
Implements ITextControl
Dim instance As DataBoundLiteralControl
public sealed class DataBoundLiteralControl : Control, ITextControl
public ref class DataBoundLiteralControl sealed : public Control, ITextControl
public final class DataBoundLiteralControl extends Control implements ITextControl
public final class DataBoundLiteralControl extends Control implements ITextControl
DataBoundLiteralControl 類別會將它的 Text 屬性值保存在檢視狀態上。
下列程式碼範例會建立取得 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.Object
System.Web.UI.Control
System.Web.UI.DataBoundLiteralControl
這個型別的所有公用靜態成員 (即 Visual Basic 中的 Shared 成員) 都是安全執行緒。並非所有的執行個體成員均為安全執行緒。
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 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
.NET Framework
支援版本:2.0、1.1、1.0