TemplateControl.ParseControl メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As TemplateControl Dim content As String Dim returnValue As Control returnValue = instance.ParseControl(content)
戻り値
解析された Control。

.ascx ファイルに示されているように、content パラメータにはユーザー コントロールが格納されます。ParseControl メソッドではコンパイルが行われないため、この文字列にコードを格納することはできません。

ParseControl メソッドを使用して Button Web サーバー コントロールを作成し、myPlaceholder という名前の PlaceHolder Web サーバー コントロールの ControlCollection コレクションにその結果を追加するコード例を次に示します。
<%@ Page language="vb" Debug="true" %> <HTML> <HEAD> <script runat="server"> ' System.Web.UI.TemplateControl.ParseControl; ' The following example demonstrates the method 'ParseControl' of class TemplateControl. ' Since TemplateControl is abstract, this sample has been written using 'Page' class which derives from ' 'TemplateControl' class. ' A button object is created by passing a string to contstruct a button using ASP syntax, to the ' 'ParseControl' method. This button is added as one of the child controls of the page and displayed. Sub Page_Load(sender As Object, e As System.EventArgs) Dim c As Control c = ParseControl("<asp:button text='Click here!' runat='server' />") myPlaceholder.Controls.Add(c) End Sub 'Page_Load </script> </HEAD> <body> <form runat=server> <asp:placeholder id = myPlaceholder runat=server /> </form> </body> </HTML>
<%@ Page language="c#" Debug="true" %> <HTML> <HEAD> <script runat="server"> // System.Web.UI.TemplateControl.ParserControl; // The following example demonstrates the method 'ParseControl' of class TemplateControl. // Since TemplateControl is abstract, this sample has been written using 'Page' class which derives from // 'TemplateControl' class. // A button object is created by passing a string to contstruct a button using ASP syntax, to the // 'ParseControl' method. This button is added as one of the child controls of the page and displayed. void Page_Load(object sender, System.EventArgs e) { Control c = ParseControl("<asp:button text='Click here!' runat='server' />"); myPlaceholder.Controls.Add(c); } </script> </HEAD> <body> <form runat=server> <asp:placeholder id = myPlaceholder runat=server /> </form> </body> </HTML>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からTemplateControl.ParseControl メソッドを検索する場合は、下記のリンクをクリックしてください。

- TemplateControl.ParseControl メソッドのページへのリンク