提供組織控制項的群組機制。
public class System.Web.UI.MobileControls.Panel :
System.Web.UI.MobileControls.MobileControl,
System.Web.UI.MobileControls.ITemplateable
備註
表單中的面板可以遞迴巢狀化。面板會呈現內部的控制項,面板中的控制項可以繼承面板上設定的屬性 (Attribute)。
面板可用來提供下列功能:
- 以邏輯方式集結控制項,便於顯示或隱藏。
- 定義能動態建立或移除控制項的便利容器 (Container)。
- 在面板上設定控制項,以使用單一點將樣式屬性套用至控制項集合。樣式繼承 (Inheritance) 會套用至面板,因此面板中的控制項可以繼承面板上設定的屬性。
- 提供重新編頁時哪些控制項要在一起的提示給 ASP.NET 網頁架構。根據預設,頁面上的面板內容要放在一起。您可以設定面板的 Paginate 屬性來修改這個行為。
您可以在 Panel 控制項的文字內容的常值文字中包含它隨附的標記 (Markup Tag)。如需詳細資訊,請參閱表單標記中的常值文字。
範例
程式碼範例的第一個部份,設定頁面載入期間的面板屬性。第二個部份定義能操作面板屬性以回應按選命令的函式。
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="VB" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server" language="vb">
Public Sub Page_Load(sender As Object, e As EventArgs)
Panel1.Wrapping = Wrapping.NoWrap
Panel1.Alignment = Alignment.Center
Panel1.StyleReference = "title"
End Sub
Public Sub MakeFontRed(sender As Object, e As EventArgs)
Panel1.ForeColor = System.Drawing.Color.Red
End Sub
Public Sub MakeFontBlue(sender As Object, e As EventArgs)
Panel1.ForeColor = System.Drawing.Color.Blue
End Sub
</script>
<mobile:Form runat="server" id="Form1">
<mobile:Panel runat="server" id="Panel1">
<mobile:Textview runat="server" id="TextView1">
A Panel provides a grouping mechanism for organizing controls.
</mobile:TextView>
</mobile:Panel>
<mobile:Command runat="server" id="Command1" Text="Make Font Red"
OnClick="MakeFontRed"/>
<mobile:Command runat="server" id="Command2" Text="Make Font Blue"
OnClick="MakeFontBlue"/>
</mobile:Form>
[C#]
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server" language="c#">
public void Page_Load(Object sender, EventArgs e)
{
Panel1.Wrapping = System.Web.UI.MobileControls.Wrapping.NoWrap;
Panel1.Alignment = System.Web.UI.MobileControls.Alignment.Center;
Panel1.StyleReference = "title";
}
public void MakeFontRed(Object sender, EventArgs e)
{
Panel1.ForeColor = System.Drawing.Color.Red;
}
public void MakeFontBlue(Object sender, EventArgs e)
{
Panel1.ForeColor = System.Drawing.Color.Blue;
}
</script>
<mobile:Form runat="server" id="Form1">
<mobile:Panel runat="server" id="Panel1">
<mobile:Textview runat="server" id="TextView1">
A Panel provides a grouping mechanism for organizing controls.
</mobile:TextView>
</mobile:Panel>
<mobile:Command runat="server" id="Command1" Text="Make Font Red"
OnClick="MakeFontRed"/>
<mobile:Command runat="server" id="Command2" Text="Make Font Blue"
OnClick="MakeFontBlue"/>
</mobile:Form>
需求
命名空間:System.Web.UI.MobileControls
**組件:**System.Web.Mobile
請參閱
Panel 控制項 | 實作樣板化的呈現 | 樣板集和樣板化控制項 | 用容器組織內容