Freigeben über


LiteralControl-Konstruktor (String)

Initialisiert eine neue Instanz der LiteralControl-Klasse mit dem angegebenen Text.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Public Sub New ( _
    text As String _
)
'Usage
Dim text As String

Dim instance As New LiteralControl(text)
public LiteralControl (
    string text
)
public:
LiteralControl (
    String^ text
)
public LiteralControl (
    String text
)
public function LiteralControl (
    text : String
)

Parameter

  • text
    Der auf der angeforderten Webseite wiederzugebende Text.

Beispiel

Im folgenden Codebeispiel werden mit dem LiteralControl-Konstruktor zwei Instanzen der LiteralControl-Klasse erstellt. Die beiden Instanzen geben öffnende und schließende Tags für ein H3-HTML-Element wieder, und sie enthalten den Text, der innerhalb der H3-Tags angezeigt werden soll.

' 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

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

LiteralControl-Klasse
LiteralControl-Member
System.Web.UI-Namespace
LiteralControl.Text