Form Class

Provides the capability to group controls together.

public class System.Web.UI.MobileControls.Form : 
   System.Web.UI.MobileControls.Panel, 
   System.Web.UI.IPostBackEventHandler

Remarks

A form represents the outermost grouping of controls within an ASP.NET mobile Web Forms page. An individual mobile Web Forms page can contain multiple forms at the outermost level. Forms cannot be nested; use Panel controls if you want to nest containers. See Forms for more information.

To display a specific form, either set the ActiveForm property on the current page to the desired form, or set the NavigateURL property in a Link control to the desired form.

You can include literal text along with its accompanying markup tags in the text contents of the Form control. See Literal Text Inside Form Markup for more information.

When using templates, it is important to remember that the Form control creates instances of templates in the OnInit method for the form. The OnInit method for the form is called before Page_Load and Page_Init. Also, the page constructor executes too early to set templates in the OnInit method because the form is not yet created. To correct this, hook the form's own OnInit method, and create an instance of the template there. For more information, see Implementing Templated Rendering.

Example

The following code example demonstrates some simple operations on a form.

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

Requirements

Namespace: System.Web.UI.MobileControls

Assembly: System.Web.Mobile

See Also

Form Control | Stylesheet Control | PagerStyle Class