Export (0) Print
Expand All

UpdatePanel.RenderMode Property

Gets or sets a value that indicates whether an UpdatePanel control's content is enclosed in an HTML <div> or <span> element.

Namespace:  System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public UpdatePanelRenderMode RenderMode { get; set; }
<asp:UpdatePanel RenderMode="UpdatePanelRenderMode" />

Property Value

Type: System.Web.UI.UpdatePanelRenderMode
One of the UpdatePanelRenderMode values. The default is Block so that the content of the panel is enclosed in an HTML <div> element.

If the RenderMode property is set to Inline, the content of an UpdatePanel control is rendered inside an HTML <span> element. If the RenderMode property is set to Block, it is rendered inside an HTML <div> element.

The following example shows how to set the RenderMode property declaratively. The UpdatePanel control named UpdatePanel1 is rendered in an HTML <span> element. If the RenderMode property were set to Block, the resulting paragraph would appear disjointed because of the way in which the HTML <div> element is rendered.



<%@ 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>


.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft