ControlParser.ParseControl 方法

定义

根据指定的标记创建控件。

重载

ParseControl(IDesignerHost, String)

使用指定的设计器宿主,根据指定的标记创建控件。

ParseControl(IDesignerHost, String, String)

使用指定的设计器宿主和指令,根据指定的标记创建控件。

ParseControl(IDesignerHost, String)

使用指定的设计器宿主,根据指定的标记创建控件。

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

参数

designerHost
IDesignerHost

作为页面的设计器宿主的 IDesignerHost 实例。

controlText
String

控件的 HTML 标记。

返回

Control

controlText 表示的 Control;否则,如果分析器无法生成控件,则为 null

例外

参数无效。

示例

下面的代码示例演示如何从 HTML 标记文本创建控件。 此代码示例是为类提供的大型示例的 ControlParser 一部分。

// 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())

注解

该方法ParseControl使用设计器主机的服务访问表示 ASP.NET 网页上的寄存器指令的字符串。 设计器主机服务是通过 ReferenceManager 对象的属性获取的,或者如果该属性 RootDesigner 不可用,则 IWebFormReferenceManager 为该服务。

如果分析程序无法生成控件,该方法 ParseControl 将引发异常。

另请参阅

适用于

ParseControl(IDesignerHost, String, String)

使用指定的设计器宿主和指令,根据指定的标记创建控件。

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

参数

designerHost
IDesignerHost

作为页面的设计器宿主的 IDesignerHost 实例。

controlText
String

控件的 HTML 标记文本。

directives
String

要包括在控件代码中的页面指令。

返回

Control

controlText 所表示的 Control

例外

参数无效。

示例

下面的代码示例演示如何从 HTML 标记文本创建控件。 此代码示例是为类提供的大型示例的 ControlParser 一部分。

// 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())

注解

该方法ParseControl使用设计器主机的服务访问表示 ASP.NET 网页上的寄存器指令的字符串。 设计器主机服务是通过 ReferenceManager 对象的属性获取的,或者如果该属性 RootDesigner 不可用,则 IWebFormReferenceManager 为该服务。

如果分析程序无法生成控件,该方法 ParseControl 将引发异常。

另请参阅

适用于