ControlParser.ParseControls(IDesignerHost, String) 方法
定义
使用指定的设计器宿主,根据指定的标记创建控件的数组。Creates an array of controls from the specified markup using the specified designer host.
public:
static cli::array <System::Web::UI::Control ^> ^ ParseControls(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::String ^ controlText);
public static System.Web.UI.Control[] ParseControls (System.ComponentModel.Design.IDesignerHost designerHost, string controlText);
static member ParseControls : System.ComponentModel.Design.IDesignerHost * string -> System.Web.UI.Control[]
Public Shared Function ParseControls (designerHost As IDesignerHost, controlText As String) As Control()
参数
- designerHost
- IDesignerHost
作为页面的设计器宿主的 IDesignerHost 实例。An IDesignerHost instance that is the designer host for the page.
- controlText
- String
表示控件标记的集合的字符串。A string that represents a collection of markup for controls.
返回
- Control[]
从 controlText 分析得出的 Control 元素的数组;否则,如果分析器无法生成控件,则为 null。An array of Control elements, parsed from controlText; otherwise, null, if the parser cannot build the controls.
例外
designerHost 为 null。designerHost is null.
- 或 --or-
controlText 为 null 或空字符串 ("")。controlText is null or an empty string ("").
注解
ParseControls方法使用设计器宿主的服务在 ASP.NET 网页上访问表示 register 指令的字符串。The ParseControls method accesses the string representing the register directives on the ASP.NET Web page using the services of the designer host. 设计器宿主服务通过对象的 ReferenceManager 属性获取 RootDesigner ,如果该服务不可用,则通过该 IWebFormReferenceManager 服务获取。Designer host services are acquired through the ReferenceManager property of the RootDesigner object, or if that is not available, the IWebFormReferenceManager service.
ParseControls如果分析器无法生成参数中的控件,则该方法将引发异常 controlText 。The ParseControls method throws an exception if the parser cannot build the controls from the controlText parameter.