MobilePage.ActiveForm Property
Gets or sets the page's currently active form. This API is obsolete. For information about how to develop ASP.NET mobile applications, see the www.asp.net/mobile Web site.
Assembly: System.Web.Mobile (in System.Web.Mobile.dll)
| Exception | Condition |
|---|---|
| Exception | The page does not contain any forms. |
When a page is initially rendered, the first form in the page is automatically made active. On subsequent postbacks, another form might be made active, either by programmatically setting this property, or as a result of user navigation through a Link control.
The following example demonstrates how to use the ActiveForm property of a Form control. If the current mobile device allows for access keys for controls, the button will display the access key that submits the form.
Note |
|---|
The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Forms Page Code Model. |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Import Namespace="System.Web.Mobile" %> <script runat="server"> Private Sub Command_OnClick(ByVal sender As Object, ByVal e As EventArgs) ' Display the other form If ActiveForm.ID = "Form1" Then ActiveForm = Form2 Else ActiveForm = Form1 End If End Sub Public Function isAccessKey(ByVal caps As MobileCapabilities, _ ByVal optValue As String) As Boolean ' Determine if the browser is not a Web crawler ' and can use access keys If Not caps.Crawler AndAlso caps.SupportsAccesskeyAttribute Then Return True End If Return False End Function </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <mobile:Form runat="server" id="Form1" > <mobile:Label ID="Label1" Runat="server">This is Form1</mobile:Label> <mobile:Command id="cmd1" runat="server" Text="No AccessKey" onClick="Command_OnClick"> <DeviceSpecific> <Choice Filter="isAccessKey" Text="AccessKey is 1"/> </DeviceSpecific> </mobile:Command> <mobile:Label id="Label2" runat="server" /> </mobile:Form> <mobile:Form ID="Form2" Runat="server"> <mobile:Label ID="Label3" Runat="server">This is Form2</mobile:Label> <mobile:Command id="cmd2" runat="server" text="Back to Form1" onClick="Command_OnClick"> <DeviceSpecific> <Choice Filter="isAccessKey" Text="1 is AccessKey" AccessKey="1" /> </DeviceSpecific> </mobile:Command> </mobile:Form> </body> </html>
Available since 1.1
