UpdatePanel.RenderMode Propriété

Définition

Obtient ou définit une valeur qui indique si un contenu de contrôle UpdatePanel est compris dans un <div> HTML ou un élément <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

Valeur de propriété

Une des valeurs de l'objet UpdatePanelRenderMode. La valeur par défaut est Block afin que le contenu du panneau soit compris dans un élément <div> HTML.

Exemples

L’exemple suivant montre comment définir la RenderMode propriété de manière déclarative. Le UpdatePanel contrôle nommé UpdatePanel1 est affiché dans un élément HTML <span> . Si la RenderMode propriété était définie sur Block, le paragraphe résultant apparaît disjoint en raison de la façon dont l’élément HTML <div> est rendu.


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

Remarques

Si la RenderMode propriété a la Inlinevaleur , le contenu d’un UpdatePanel contrôle est affiché à l’intérieur d’un élément HTML <span> . Si la propriété a la RenderModeBlockvaleur , elle est affichée à l’intérieur d’un élément HTML <div> .

S’applique à

Voir aussi