TemplateControl.ParseControl 메서드

정의

ASP.NET 웹 페이지나 사용자 정의 컨트롤에서 입력 문자열을 Control 개체로 구문 분석합니다.

오버로드

ParseControl(String)

Web Forms 페이지나 사용자 정의 컨트롤에서 입력 문자열을 Control로 구문 분석합니다.

ParseControl(String, Boolean)

ASP.NET 웹 페이지나 사용자 정의 컨트롤에서 입력 문자열을 Control 개체로 구문 분석합니다.

설명

ParseControl .NET Framework 버전 3.5에서에서 도입 되었습니다. 자세한 내용은 버전 및 종속성을 참조하세요.

ParseControl(String)

Web Forms 페이지나 사용자 정의 컨트롤에서 입력 문자열을 Control로 구문 분석합니다.

public:
 System::Web::UI::Control ^ ParseControl(System::String ^ content);
public System.Web.UI.Control ParseControl (string content);
member this.ParseControl : string -> System.Web.UI.Control
Public Function ParseControl (content As String) As Control

매개 변수

content
String

사용자 정의 컨트롤을 포함하는 문자열입니다.

반환

Control

구문 분석된 Control입니다.

예제

다음 코드 예제에서는 메서드를 사용 하 여 ParseControl 웹 서버 컨트롤을 Button 만든 다음 명명 myPlaceholder된 웹 서버 컨트롤의 컬렉션에 PlaceHolder 결과 추가 하는 ControlCollection 방법을 보여 줍니다.

<%@ Page language="c#" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ASP.NET Example</title>
<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 id="form1" runat="server">
      <asp:placeholder id ="myPlaceholder" runat="server" />
    </form>
  </body>
</html>
<%@ Page language="vb" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ASP.NET Example</title>
<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 id="form1" runat="server">
      <asp:placeholder id ="myPlaceholder" runat="server" />
    </form>
  </body>
</html>

설명

매개 변수에는 content .ascx 파일에서 찾을 수 있는 것과 같은 사용자 컨트롤이 포함됩니다. 메서드가 컴파일을 유발하지 않으므로 이 문자열은 ParseControl 코드를 포함할 수 없습니다.

추가 정보

적용 대상

ParseControl(String, Boolean)

ASP.NET 웹 페이지나 사용자 정의 컨트롤에서 입력 문자열을 Control 개체로 구문 분석합니다.

public:
 System::Web::UI::Control ^ ParseControl(System::String ^ content, bool ignoreParserFilter);
public System.Web.UI.Control ParseControl (string content, bool ignoreParserFilter);
member this.ParseControl : string * bool -> System.Web.UI.Control
Public Function ParseControl (content As String, ignoreParserFilter As Boolean) As Control

매개 변수

content
String

사용자 정의 컨트롤을 포함하는 문자열입니다.

ignoreParserFilter
Boolean

파서 필터를 무시할지 여부를 지정하는 값입니다.

반환

Control

구문 분석된 컨트롤입니다.

설명

매개 변수에는 content 사용자 컨트롤(.ascx 파일의 내용)이 포함됩니다. 메서드가 컴파일을 유발하지 않으므로 이 문자열은 ParseControl 코드를 포함할 수 없습니다.

매개 ignoreParserFilter 변수를 사용하면 클래스를 PageParserFilter 무시할 수 있습니다. 클래스는 PageParserFilter 구문 분석 시 페이지에서 항목이 허용되는지 여부를 확인하기 위해 ASP.NET 파서에서 사용됩니다.

적용 대상