Export (0) Print
Expand All

TemplateControl.ParseControl Method

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

[Visual Basic]
Public Function ParseControl( _
   ByVal content As String _
) As Control
public Control ParseControl(
 string content
public: Control* ParseControl(
 String* content
public function ParseControl(
   content : String
) : Control;


A String that contains a user control.

Return Value

Returns the parsed Control.


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


[Visual Basic, C#] The following example creates a Button Web server control using the ParseControl method and then adds the result to the ControlCollection of a PlaceHolder Web server control named myPlaceholder.

[Visual Basic] 
Sub Page_Load(sender As Object, e As System.EventArgs)
   Dim c As Control 
   c = ParseControl("<asp:button text='Click here!' runat='server' />")
End Sub 'Page_Load

void Page_Load(object sender, System.EventArgs e)
  Control c = ParseControl("<asp:button text='Click here!' runat='server' />");

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

TemplateControl Class | TemplateControl Members | System.Web.UI Namespace

© 2014 Microsoft