UpdatePanel.ContentTemplateContainer 속성

정의

프로그래밍 방식으로 자식 컨트롤을 추가할 수 있는 컨트롤 개체를 가져옵니다.

public:
 property System::Web::UI::Control ^ ContentTemplateContainer { System::Web::UI::Control ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.Control ContentTemplateContainer { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ContentTemplateContainer : System.Web.UI.Control
Public ReadOnly Property ContentTemplateContainer As Control

속성 값

Control

Control 컨트롤의 내용을 정의하는 UpdatePanel 개체입니다.

특성

예제

다음 예제에서는 프로그래밍 방식으로 컨트롤의 ContentTemplateContainer 속성을 지정 하는 방법을 보여 줍니다 UpdatePanel . 컨트롤의 Label 속성은 Text 클릭할 때 Button1 설정됩니다.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        UpdatePanel up1 = new UpdatePanel();
        up1.ID = "UpdatePanel1";
        up1.UpdateMode = UpdatePanelUpdateMode.Conditional;
        Button button1 = new Button();
        button1.ID = "Button1";
        button1.Text = "Submit";
        button1.Click += new EventHandler(Button_Click);
        Label label1 = new Label();
        label1.ID = "Label1";
        label1.Text = "A full page postback occurred.";
        up1.ContentTemplateContainer.Controls.Add(button1);
        up1.ContentTemplateContainer.Controls.Add(label1);
        Page.Form.Controls.Add(up1);
    }
    protected void Button_Click(object sender, EventArgs e)
    {
        ((Label)Page.FindControl("Label1")).Text = "Panel refreshed at " +
            DateTime.Now.ToString();
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1"
                               runat="server" />
        </div>
    </form>
</body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim lbl As Label
        lbl = Page.FindControl("Label1")
        lbl.Text = "Panel refreshed at " & DateTime.Now.ToString()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim up1 As UpdatePanel
        up1 = New UpdatePanel()
        up1.ID = "UpdatePanel1"
        Dim button1 As Button
        button1 = New Button()
        button1.ID = "Button1"
        button1.Text = "Submit"
        AddHandler button1.Click, AddressOf Button_Click
        Dim label1 As Label
        label1 = New Label()
        label1.ID = "Label1"
        label1.Text = "A full page postback occurred."
        up1.ContentTemplateContainer.Controls.Add(button1)
        up1.ContentTemplateContainer.Controls.Add(label1)
        Page.Form.Controls.Add(up1)
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" 
                               runat="server" />
        </div>
    </form>
</body>
</html>

설명

ContentTemplateContainer 속성을 사용하면 인터페이스에서 상속되는 사용자 지정 템플릿을 UpdatePanel 정의하지 않고도 프로그래밍 방식으로 자식 컨트롤을 컨트롤에 ITemplate 추가할 수 있습니다. 선언적으로 또는 디자이너를 통해 컨트롤에 UpdatePanel 콘텐츠를 추가하는 경우 요소를 사용하여 <ContentTemplate> 속성에 ContentTemplate 콘텐츠를 추가해야 합니다.

적용 대상

추가 정보