TextBox.AddParsedSubObject-Methode
Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.
Wird überschrieben, um nur das Hinzufügen von literalen Steuerelementen als Text-Eigenschaft zuzulassen.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Protected Overrides Sub AddParsedSubObject ( _
obj As Object _
)
'Usage
Dim obj As Object
Me.AddParsedSubObject(obj)
protected override void AddParsedSubObject (
Object obj
)
protected:
virtual void AddParsedSubObject (
Object^ obj
) override
protected void AddParsedSubObject (
Object obj
)
protected override function AddParsedSubObject (
obj : Object
)
Parameter
- obj
Ein Object, das das analysierte Element darstellt.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie Sie die AddParsedSubObject-Methode in einem benutzerdefinierten Serversteuerelement überschreiben können, sodass die Text-Eigenschaft immer auf die Text-Eigenschaft des analysierten Objekts festgelegt wird, wenn es sich bei dem analysierten Objekt um ein Literal-Steuerelement handelt. Andernfalls wird eine Ausnahme ausgelöst.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - AddParsedSubObject - VB.NET Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - AddParsedSubObject - VB.NET Example</h3>
<aspSample:CustomTextBoxAddParsedSubObject id="TextBox1"
runat="server">Hello World!</aspSample:CustomTextBoxAddParsedSubObject>
</form>
</body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - AddParsedSubObject - C# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - AddParsedSubObject - C# Example</h3>
<aspSample:CustomTextBoxAddParsedSubObject
id="TextBox1"
runat="server">Hello World!
</aspSample:CustomTextBoxAddParsedSubObject>
</form>
</body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - AddParsedSubObject - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="get" runat="server" title="Custom TextBox - AddParsedSubObject - VJ# Example" language="VJ#">
<h3>Custom TextBox - AddParsedSubObject - VJ# Example</h3>
<aspSample:CustomTextBoxAddParsedSubObject
id="TextBox1"
runat="server"
text="Hello World!">
</aspSample:CustomTextBoxAddParsedSubObject>
</form>
</body>
</HTML>
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomTextBoxAddParsedSubObject
Inherits System.Web.UI.WebControls.TextBox
Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
' If the object is a LiteralControl, then set this control's Text property.
If TypeOf obj Is System.Web.UI.LiteralControl Then
Me.Text = CType(obj, System.Web.UI.LiteralControl).Text
Else
Throw New System.Web.HttpException("You cannot have children controls of type " + obj.GetType().Name.ToString())
End If
End Sub
End Class
End Namespace
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomTextBoxAddParsedSubObject : System.Web.UI.WebControls.TextBox
{
protected override void AddParsedSubObject(object obj)
{
// If the object is a LiteralControl, then set this control's Text property.
if (obj is System.Web.UI.LiteralControl)
{
this.Text = ((System.Web.UI.LiteralControl)obj).Text;
}
else
{
throw new System.Web.HttpException("You cannot have a child control of type " + obj.GetType().Name.ToString());
}
}
}
}
package Samples.AspNet.JSL.Controls;
public class CustomTextBoxAddParsedSubObject
extends System.Web.UI.WebControls.TextBox
{
protected void AddParsedSubObject(Object obj)
throws System.Web.HttpException
{
// If the object is a LiteralControl, then set this control's
// Text property.
if (obj instanceof System.Web.UI.LiteralControl) {
this.set_Text(((System.Web.UI.LiteralControl)obj).get_Text());
}
else {
throw new System.Web.HttpException("You cannot have a child "
+ "control of type "
+ obj.GetType().get_Name().ToString());
}
} //AddParsedSubObject
} //CustomTextBoxAddParsedSubObject
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
TextBox-Klasse
TextBox-Member
System.Web.UI.WebControls-Namespace
Control.AddParsedSubObject