TextBox.AddParsedSubObject Method

This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Overridden to allow only literal controls to be added as the Text property.

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

protected:
virtual void AddParsedSubObject (
	Object^ obj
) override
protected void AddParsedSubObject (
	Object obj
)
protected override function AddParsedSubObject (
	obj : Object
)
Not applicable.

Parameters

obj

An Object that represents the parsed element.

Exception typeCondition

HttpException

obj is not of type LiteralControl.

The following code example demonstrates how to override the AddParsedSubObject method in a custom server control so that it always sets the Text property to the parsed object's Text property if the parsed object is a Literal control, and throws an exception otherwise.

Security noteSecurity Note:

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio).

No code example is currently available or this language may not be supported.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Custom TextBox - AddParsedSubObject - VJ# Example</title>
    </head>
    <body>
        <form id="Form1" method="get" runat="server" title="Custom TextBox - AddParsedSubObject - VJ# Example" lang="VJ#">
            <h3>Custom TextBox - AddParsedSubObject - VJ# Example</h3>
            
            <aspSample:CustomTextBoxAddParsedSubObject 
              id="TextBox1" 
              runat="server"
              text="Hello World!">
            </aspSample:CustomTextBoxAddParsedSubObject>
            
        </form>
    </body>
</html>

No code example is currently available or this language may not be supported.
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

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: