Freigeben über


HtmlTextArea.AddParsedSubObject-Methode

Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.

Benachrichtigt das HtmlTextArea-Steuerelement, dass ein Objekt analysiert wurde, und fügt das Objekt im ControlCollection-Objekt des HtmlTextArea-Steuerelements hinzu.

Namespace: System.Web.UI.HtmlControls
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.

Ausnahmen

Ausnahmetyp Bedingung

HttpException

Das vom obj-Parameter angegebene Objekt kann nur vom Typ LiteralControl oder DataBoundLiteralControl sein.

Hinweise

Die AddParsedSubObject-Methode fügt ein Objekt nur dann in der ControlCollection des HtmlTextArea-Steuerelements hinzu, wenn das Objekt vom Typ LiteralControl oder DataBoundLiteralControl ist, andernfalls wird eine HttpException ausgelöst.

Die AddParsedSubObject-Methode wird hauptsächlich von Entwicklern von Steuerelementen zum Erweitern der Funktionalität des HtmlTextArea-Steuerelements verwendet.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie die AddParsedSubObject-Methode in einem benutzerdefinierten HtmlTextArea-Serversteuerelement überschrieben wird, damit sie immer bestimmt, ob das analysierte Objekt vom Typ LiteralControl oder DataBoundLiteralControl ist.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>

<script runat="server">

  Sub Page_Load(sender As Object, e As EventArgs)

    HtmlTextArea1.Value = "Hello Html Text Area World."

  End Sub

</script>

<html>
  <head>
    <title>Custom HtmlTextArea AddParsedSubObject Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post" 
          runat="server">

      <h3>Custom HtmlTextArea AddParsedSubObject Example</h3>

      <aspSample:CustomHtmlTextAreaAddParsedSubObject 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>

<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {
    HtmlTextArea1.Value = "Hello Html Text Area World.";
  }

</script>

<html>
  <head>
    <title>Custom HtmlTextArea AddParsedSubObject Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post" 
          runat="server">

      <h3>Custom HtmlTextArea AddParsedSubObject Example</h3>

      <aspSample:CustomHtmlTextAreaAddParsedSubObject 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50"/>
        
    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSl.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom HtmlTextArea - AddParsedSubObject - VJ# Example</title>
    <script runat="server">
    void Page_Load(Object sender, EventArgs e) 
    {
        HtmlTextArea1.set_Value("Hello Html Text Area World.");
    } //Page_Load
    </script>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom HtmlTextArea - AddParsedSubObject - VJ# Example</h3>

      <aspSample:CustomHtmlTextAreaAddParsedSubObject 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
        </form>
    </body>
</HTML>
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls

Public NotInheritable Class CustomHtmlTextAreaAddParsedSubObject
   Inherits System.Web.UI.HtmlControls.HtmlTextArea

        <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
        Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)

            ' If the object is a LiteralControl or a DataBoundLiteralControl control, 
            ' then pass the object to the base class's AddParsedSubObject method.
            If TypeOf obj Is System.Web.UI.LiteralControl OrElse TypeOf obj Is System.Web.UI.DataBoundLiteralControl Then
                MyBase.AddParsedSubObject(obj)
            Else
                Throw New System.Web.HttpException("You cannot have a child control 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 CustomHtmlTextAreaAddParsedSubObject : System.Web.UI.HtmlControls.HtmlTextArea
  {
    protected override void AddParsedSubObject(object obj)
    {
      // If the object is a LiteralControl or a DataBoundLiteralControl control, 
      // then pass the object to the base class's AddParsedSubObject method.
      if (obj is System.Web.UI.LiteralControl || 
          obj is System.Web.UI.DataBoundLiteralControl)
      {
        base.AddParsedSubObject(obj);
      }
      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 CustomHtmlTextAreaAddParsedSubObject
   extends System.Web.UI.HtmlControls.HtmlTextArea
{
    protected void AddParsedSubObject(Object obj)
        throws System.Web.HttpException
    {
        // If the object is a LiteralControl or a DataBoundLiteralControl  
        // control, then pass the object to the base's AddParsedSubObject method.
        if (obj instanceof System.Web.UI.LiteralControl 
            || obj instanceof System.Web.UI.DataBoundLiteralControl) {
            super.AddParsedSubObject(obj);
        }
        else {
            throw new System.Web.
                HttpException("You cannot have a child control of type " 
                + obj.GetType().get_Name().ToString());
        }
    } //AddParsedSubObject
} //CustomHtmlTextAreaAddParsedSubObject

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

HtmlTextArea-Klasse
HtmlTextArea-Member
System.Web.UI.HtmlControls-Namespace
Control.AddParsedSubObject
LiteralControl
DataBoundLiteralControl

Weitere Ressourcen

HTML-Serversteuerelemente