按一下以給予評分及指教
MSDN
MSDN Library
.NET 開發
先前版本
類別庫參考
System.Web.UI

  開啟低頻寬檢視
本頁僅適用於
Microsoft Visual Studio 2005/.NET Framework 2.0

其他版本也適用於下列軟體:
.NET Framework 類別庫
DataBoundLiteralControl 類別

保留資料繫結運算式和靜態常值文字。這個類別無法被繼承。

命名空間: System.Web.UI
組件: System.Web (在 system.web.dll 中)

Visual Basic (宣告)
Public NotInheritable Class DataBoundLiteralControl
    Inherits Control
    Implements ITextControl
Visual Basic (使用方式)
Dim instance As DataBoundLiteralControl
C#
public sealed class DataBoundLiteralControl : Control, ITextControl
C++
public ref class DataBoundLiteralControl sealed : public Control, ITextControl
J#
public final class DataBoundLiteralControl extends Control implements ITextControl
JScript
public final class DataBoundLiteralControl extends Control implements ITextControl

DataBoundLiteralControl 類別會將它的 Text 屬性值保存在檢視狀態上。

下列程式碼範例會建立取得 DataBoundLiteralControl 物件並顯示此物件之 Text 屬性的類別。

Visual Basic
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
C#
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>");

      }
    }
   }    
}

J#
/*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
社群內容   什麼是社群內容?
新增內容 RSS  註解
Processing
© 2009 Microsoft Corporation. 著作權所有,並保留一切權利。 使用規定  |  商標  |  隱私權聲明
Page view tracker