Επεξεργασία

Κοινή χρήση μέσω


ControlParser.ParseControl Method

Definition

Creates a control from the specified markup.

Overloads

ParseControl(IDesignerHost, String)

Creates a control from the specified markup using the specified designer host.

ParseControl(IDesignerHost, String, String)

Creates a control from the specified markup using the specified designer host and directives.

ParseControl(IDesignerHost, String)

Creates a control from the specified markup using the specified designer host.

public:
 static System::Web::UI::Control ^ ParseControl(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::String ^ controlText);
public static System.Web.UI.Control ParseControl (System.ComponentModel.Design.IDesignerHost designerHost, string controlText);
static member ParseControl : System.ComponentModel.Design.IDesignerHost * string -> System.Web.UI.Control
Public Shared Function ParseControl (designerHost As IDesignerHost, controlText As String) As Control

Parameters

designerHost
IDesignerHost

An IDesignerHost instance that is the designer host for the page.

controlText
String

The HTML markup for the control.

Returns

The Control that controlText represents; otherwise, null, if the parser cannot build the control.

Exceptions

A parameter is not valid.

Examples

The following code example shows how to create a control from HTML markup text. This code example is part of a larger example provided for the ControlParser class.

// Create a Web control from the persisted control String*.
System::Web::UI::Control^ ctrl = ControlParser::ParseControl( host, inputForm->tbox->Text->Trim() );
// Create a Web control from the HTML markup.
System.Web.UI.Control ctrl =
    ControlParser.ParseControl(host, inputForm.TBox.Text.Trim());
' Create a Web control from the persisted control string.
Dim ctrl As System.Web.UI.Control = ControlParser.ParseControl(host, inputForm.TxBox.Text.Trim())

Remarks

The ParseControl method accesses the string representing the register directives on the ASP.NET Web page using the services of the designer host. Designer host services are acquired through the ReferenceManager property of the RootDesigner object, or if that is not available, the IWebFormReferenceManager service.

The ParseControl method throws an exception if the parser cannot build the control.

See also

Applies to

ParseControl(IDesignerHost, String, String)

Creates a control from the specified markup using the specified designer host and directives.

public:
 static System::Web::UI::Control ^ ParseControl(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::String ^ controlText, System::String ^ directives);
public static System.Web.UI.Control ParseControl (System.ComponentModel.Design.IDesignerHost designerHost, string controlText, string directives);
static member ParseControl : System.ComponentModel.Design.IDesignerHost * string * string -> System.Web.UI.Control
Public Shared Function ParseControl (designerHost As IDesignerHost, controlText As String, directives As String) As Control

Parameters

designerHost
IDesignerHost

An IDesignerHost instance that is the designer host for the page.

controlText
String

The text of the HTML markup for the control.

directives
String

The page directives to include in the code for the control.

Returns

The Control that controlText represents.

Exceptions

A parameter is not valid.

Examples

The following code example shows how to create a control from HTML markup text. This code example is part of a larger example provided for the ControlParser class.

// Create a Web control from the persisted control String*.
System::Web::UI::Control^ ctrl = ControlParser::ParseControl( host, inputForm->tbox->Text->Trim() );
// Create a Web control from the HTML markup.
System.Web.UI.Control ctrl =
    ControlParser.ParseControl(host, inputForm.TBox.Text.Trim());
' Create a Web control from the persisted control string.
Dim ctrl As System.Web.UI.Control = ControlParser.ParseControl(host, inputForm.TxBox.Text.Trim())

Remarks

The ParseControl method accesses the string representing the register directives on the ASP.NET Web page using the services of the designer host. Designer host services are acquired through the ReferenceManager property of the RootDesigner object, or if that is not available, the IWebFormReferenceManager service.

The ParseControl method throws an exception if the parser cannot build the control.

See also

Applies to