다음을 통해 공유


UpdatePanel.RenderMode 속성

정의

UpdatePanel 컨트롤의 내용이 HTML <div> 또는 <span> 요소로 묶이는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property System::Web::UI::UpdatePanelRenderMode RenderMode { System::Web::UI::UpdatePanelRenderMode get(); void set(System::Web::UI::UpdatePanelRenderMode value); };
public System.Web.UI.UpdatePanelRenderMode RenderMode { get; set; }
member this.RenderMode : System.Web.UI.UpdatePanelRenderMode with get, set
Public Property RenderMode As UpdatePanelRenderMode

속성 값

UpdatePanelRenderMode

UpdatePanelRenderMode 값 중 하나입니다. 기본값은 Block이며, 이때 패널의 내용은 HTML <div> 요소로 묶입니다.

예제

다음 예제에서는 선언적으로 속성을 설정 RenderMode 하는 방법을 보여 있습니다. UpdatePanel 명명 UpdatePanel1 된 컨트롤은 HTML <span> 요소에서 렌더링됩니다. 속성이 RenderMode 설정된 Block경우 HTML <div> 요소가 렌더링되는 방식 때문에 결과 단락이 연결되지 않은 것처럼 표시됩니다.


<%@ 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 int PostBackCount
    {
        get
        {
            return (int)(ViewState["PostBackCount"] ?? 0);
        }
        set
        {
            ViewState["PostBackCount"] = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            PostBackCount++;
        }
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanelRenderMode Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1"
                               runat="server" />
            The number of times you have clicked the button is
            <asp:UpdatePanel ID="UpdatePanel1"
                             UpdateMode="Conditional"
                             RenderMode="Inline"
                             runat="server">
                <ContentTemplate>
                    <%= PostBackCount.ToString() %>
                    times. Every time you click the count is incremented. The panel
                    containing the number of times you clicked is rendered in-line.
                    <br />
                    <asp:Button ID="Button1"
                                Text="Increment"
                                runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </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 PostBackCount As Integer
        Get
            If Not ViewState("PostBackCount") Is Nothing Then
                Return ViewState("PostBackCount")
            Else : Return 0
            End If
        End Get
        Set(ByVal value As Integer)
            ViewState("PostBackCount") = Value
        End Set
    End Property
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If IsPostBack Then
            PostBackCount += 1
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanelRenderMode Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1"
                               runat="server" />
            The number of times you have clicked the button is
            <asp:UpdatePanel ID="UpdatePanel1"
                             RenderMode="Inline"
                             runat="server">
                <ContentTemplate>
                    <%= PostBackCount.ToString() %>
                    times. Every time you click the count is incremented. The panel
                    containing the number of times you clicked is rendered in-line.
                    <br />
                    <asp:Button ID="Button1"
                                Text="Increment"
                                runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>

설명

속성이 RenderMode 설정 Inline되면 컨트롤의 UpdatePanel 콘텐츠가 HTML <span> 요소 내에 렌더링됩니다. 속성이 RenderMode 설정 Block되면 HTML <div> 요소 내에서 렌더링됩니다.

적용 대상

추가 정보