UpdatePanelRenderMode 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示頁面上 UpdatePanel 控制項內容的可能配置呈現選項。
public enum class UpdatePanelRenderMode
public enum UpdatePanelRenderMode
type UpdatePanelRenderMode =
Public Enum UpdatePanelRenderMode
- 繼承
欄位
Block | 0 | 指定要呈現在 HTML |
Inline | 1 | 指定要呈現在 HTML |
範例
下列範例示範如何以宣告方式將 UpdatePanel.RenderMode 屬性設定為 Inline
。 控制項 UpdatePanel 包含字串,表示來自頁面的回傳數目。 內容會內嵌轉譯為周圍文字。
<%@ 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>
備註
列舉 UpdatePanelRenderMode
定義要用來括住控制項內容的 UpdatePanel HTML 元素。 屬性 UpdatePanel.RenderMode 必須是列舉的 UpdatePanelRenderMode
其中一個值。 控制項的內容 UpdatePanel 可以在 HTML <div>
專案或 <span>
元素內呈現。
預設 RenderMode 屬性值為 Block
。