UpdatePanelUpdateMode 열거형

정의

UpdatePanel 컨트롤의 내용에 적용할 수 있는 업데이트 모드를 나타냅니다.

public enum class UpdatePanelUpdateMode
public enum UpdatePanelUpdateMode
type UpdatePanelUpdateMode = 
Public Enum UpdatePanelUpdateMode
상속
UpdatePanelUpdateMode

필드

Always 0

페이지에서 발생한 모든 포스트백에 대해 UpdatePanel 컨트롤의 내용이 업데이트됩니다. 여기에는 비동기 포스트백이 포함됩니다.

Conditional 1

UpdatePanel 컨트롤의 콘텐츠가 업데이트되는 여러 조건을 지정합니다. 자세한 내용은 설명 부분을 참조하세요.

예제

다음 예제에서는 두 개의 선언 UpdatePanel 컨트롤입니다. 첫 번째 패널은 속성을 .로 UpdatePanel.UpdateMode Conditional설정합니다. 두 번째 패널은 UpdatePanel.UpdateMode 기본적으로 설정되어 있습니다 Always . 두 패널 외부의 단추는 메서드를 사용하여 ScriptManager.RegisterAsyncPostBackControl 비동기 포스트백 컨트롤로 등록됩니다. 단추의 클릭 이벤트 처리기는 UpdatePanel.Update 5 초 넘게 마지막 업데이트 이후 경과 된 경우 첫 번째 패널의 메서드가 호출 됩니다. 이 시나리오에서 패널 업데이트를 마지막 5 초 넘게 된 패널의 내용이 업데이트 됩니다. 두 번째 패널의 내용이 항상 업데이트 됩니다.


<%@ 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 DateTime LastUpdate
    {
        get
        {
            return (DateTime)(ViewState["LastUpdate"] ?? DateTime.Now);
        }
        set
        {
            ViewState["LastUpdate"] = value;
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (LastUpdate.AddSeconds(5.0) < DateTime.Now)
        {
            UpdatePanel1.Update();
            LastUpdate = DateTime.Now;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        ScriptManager1.RegisterAsyncPostBackControl(Button1);   
        if (!IsPostBack)
        {
            LastUpdate = DateTime.Now;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanelUpdateMode Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1"
                               runat="server" />
            <asp:Panel ID="Panel1"
                       GroupingText="UpdatePanel1"
                       runat="server">
                <asp:UpdatePanel ID="UpdatePanel1"
                                 UpdateMode="Conditional"
                                 runat="server">
                    <ContentTemplate>
                        <p>
                            The content in this UpdatePanel only refreshes if five or more
                            seconds have passed since the last refresh and the button in
                            UpdatePanel2 was clicked. The time is checked
                            server-side and the UpdatePanel.Update() method is called. Last
                            updated: <strong>
                                <%= LastUpdate.ToString() %>
                            </strong>
                        </p>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>
            <asp:Panel ID="Panel2"
                       GroupingText="UpdatePanel2"
                       runat="server">
                <asp:UpdatePanel ID="UpdatePanel2"
                                 runat="server">
                    <ContentTemplate>
                        <p>
                            This UpdatePanel always refreshes if the button is clicked.
                            Last updated: <strong>
                                <%= DateTime.Now.ToString() %>
                            </strong>
                        </p>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>
            <asp:Button ID="Button1" Text="Button1" runat="server" OnClick="Button1_Click" />
        </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 Property LastUpdate() As DateTime
        Get
            If ViewState("LastUpdate") IsNot Nothing Then
                Return ViewState("LastUpdate")
            Else : Return DateTime.Now()
            End If
        End Get
        Set(ByVal Value As DateTime)
            ViewState("LastUpdate") = Value
        End Set
    End Property

    Protected Sub Button1_Click(ByVal Sender As Object, ByVal E As EventArgs)
        If (LastUpdate.AddSeconds(5.0) < DateTime.Now) Then
            UpdatePanel1.Update()
            LastUpdate = DateTime.Now
        End If
    End Sub

    Protected Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
        ScriptManager1.RegisterAsyncPostBackControl(Button1)
        If Not IsPostBack Then
            LastUpdate = DateTime.Now
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanelUpdateMode Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1"
                               runat="server" />
            <asp:Panel ID="Panel1"
                       GroupingText="UpdatePanel1"
                       runat="server">
                <asp:UpdatePanel ID="UpdatePanel1"
                                   runat="server"
                                   UpdateMode="Conditional">
                    <ContentTemplate>
                        <p>
                            The content in this UpdatePanel only refreshes if five or more
                            seconds have passed since the last refresh and the button in
                            UpdatePanel2 was clicked. The time is checked
                            server-side and the UpdatePanel.Update() method is called. Last
                            updated: <strong>
                                <%= LastUpdate.ToString() %>
                            </strong>
                        </p>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>
            <asp:Panel ID="Panel2"
                       GroupingText="UpdatePanel2"
                       runat="server">
                <asp:UpdatePanel ID="UpdatePanel2"
                                 runat="server">
                    <ContentTemplate>
                        <p>
                            This UpdatePanel always refreshes if the button is clicked.
                            Last updated: <strong>
                                <%= DateTime.Now.ToString() %>
                            </strong>
                        </p>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>
            <asp:Button ID="Button1" Text="Button1" runat="server" OnClick="Button1_Click" />
        </div>
    </form>
</body>
</html>

설명

열거형 속성 UpdatePanelUpdateMode 에서 UpdatePanel.UpdateMode 사용 하 고 컨트롤의 콘텐츠에 대 한 가능한 업데이트 모드를 UpdatePanel 정의 합니다. 컨트롤을 UpdatePanel 사용하려면 부분 페이지 렌더링이 ScriptManager.EnablePartialRendering 수행되도록 속성이 true 필요합니다.

기본값은 UpdatePanel.UpdateMode 속성은 Always합니다.

경우는 UpdatePanel 컨트롤은 다른 UpdatePanel 컨트롤과 부모 패널에는 업데이트, 중첩된 된 패널에 관계 없이 업데이트 됩니다는 UpdateMode 속성 값입니다.

값은 Conditional 다음 조건에서 컨트롤의 UpdatePanel 콘텐츠를 업데이트합니다.

  • UpdatePanel.Update 메서드가 명시적으로 호출됩니다.

  • 컨트롤은 속성을 사용하여 UpdatePanel.Triggers 트리거로 정의되고 포스트백을 발생합니다. 이 시나리오에서는 컨트롤 패널 콘텐츠 업데이트에 대 한 트리거를 명시적입니다. 내부 또는 외부 트리거 컨트롤 수를 UpdatePanel 트리거를 정의 하는 컨트롤입니다.

  • 속성이 UpdatePanel.ChildrenAsTriggers 설정 true 되고 컨트롤의 자식 컨트롤이 UpdatePanel 포스트백을 발생합니다. 이 시나리오에서는 컨트롤의 자식 컨트롤이 UpdatePanel 제어 하는 패널을 업데이트 하는 것에 대 한 암시적 트리거입니다. 자식 컨트롤에 중첩 UpdatePanel 컨트롤 외부 하지 않게 UpdatePanel 트리거로 명시적으로 정의 하지 않는 한 업데이트 수를 제어 합니다.

적용 대상

추가 정보