提供將控制項群組在一起的功能。
public class System.Web.UI.MobileControls.Form :
System.Web.UI.MobileControls.Panel,
System.Web.UI.IPostBackEventHandler
備註
表單代表 ASP.NET Mobile Web Form 網頁的最外層控制項群組。個別 Mobile Web Form 網頁可包含位於最外層層級的多個表單。表單無法成為巢狀;如果您想要製作巢狀容器 (Container),請使用 Panel 控制項。如需詳細資訊,請參閱表單。
若要顯示特定表單,請將目前頁面上的 ActiveForm 屬性設定為想要的表單,或將 Link 控制項中的 NavigateURL 屬性設定為想要的表單。
您可在 Form 控制項的文字內容中一起包含常值 (Literal) 文字與其附隨的標記 (Markup Tag)。如需詳細資訊,請參閱表單標記中的常值文字。
當使用樣板時,請記得 Form 控制項會在 OnInit 方法中建立表單的樣板執行個體 (Instance)。會在 Page_Load 和 Page_Init 之前呼叫表單的 OnInit 方法。此外,因為表單尚未建立,所以頁面建構函式 (Constructor) 太早執行,而無法在 OnInit 方法中設定樣板。若要更正這種狀況,請攔截表單自己的 OnInit 方法,並且在該處建立樣板執行個體。如需詳細資訊,請參閱實作樣板化的呈現。
範例
下列程式碼範例示範表單的某些簡單作業。
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="VB" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script language="vb" runat=server>
Protected Sub Page_Load(sender As Object, e As EventArgs)
Form1.Alignment = Alignment.Center
Label1.Text = "Aardvark"
Label2.Text = "Bear"
End Sub
</script>
<mobile:Form id="Form1" runat="server">
<mobile:Label id="Label1" runat="server" />
<mobile:Label id="Label2" runat="server" />
</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 language="c#" runat=server>
protected void Page_Load(Object sender, EventArgs e)
{
Form1.Alignment = Alignment.Center;
Label1.Text = "Aardvark";
Label2.Text = "Bear";
}
</script>
<mobile:Form id="Form1" runat="server">
<mobile:Label id="Label1" runat="server" />
<mobile:Label id="Label2" runat="server" />
</mobile:Form>
需求
命名空間:System.Web.UI.MobileControls
**組件:**System.Web.Mobile