TemplateControl.ParseControl Method

Parses an input string into a Control object on the Web Forms page or user control.

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

public:
Control^ ParseControl (
	String^ content
)
public Control ParseControl (
	String content
)
public function ParseControl (
	content : String
) : Control
Not applicable.

Parameters

content

A string that contains a user control.

Return Value

The parsed Control.

The content parameter contains a user control, such as you would find in an .ascx file. This string cannot contain any code, because the ParseControl method never causes compilation.

The following code example demonstrates how to create a Button Web server control using the ParseControl method, and then adds the result to the ControlCollection collection of a PlaceHolder Web server control named myPlaceholder.

No code example is currently available or this language may not be supported.
void Page_Load(Object sender, System.EventArgs e)
{
    Control c = ParseControl("<asp:button text='Click here!'"
        + " runat='server' />");
    myPlaceholder.get_Controls().Add(c);
}//Page_Load

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: