MobilePage.ActiveForm 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置页的当前活动窗体。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站。
public:
property System::Web::UI::MobileControls::Form ^ ActiveForm { System::Web::UI::MobileControls::Form ^ get(); void set(System::Web::UI::MobileControls::Form ^ value); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public System.Web.UI.MobileControls.Form ActiveForm { get; set; }
[<System.ComponentModel.Bindable(false)>]
[<System.ComponentModel.Browsable(false)>]
member this.ActiveForm : System.Web.UI.MobileControls.Form with get, set
Public Property ActiveForm As Form
属性值
该页的当前活动窗体。
- 属性
例外
该页不包含任何窗体。
示例
以下示例演示如何使用 ActiveForm 控件的 Form 属性。 如果当前移动设备允许控件的访问密钥,该按钮将显示提交表单的访问密钥。
注意
下面的代码示例使用单文件代码模型,如果直接复制到代码隐藏文件中,可能无法正常工作。 必须将此代码示例复制到扩展名为 .aspx 的空文本文件中。 有关详细信息,请参阅 ASP.NET Web 窗体页代码模型。
<%@ Page Language="C#"
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">
// <Snippet2>
private void Command_OnClick(object sender, EventArgs e)
{
// Display the other form
if (ActiveForm.ID == "Form1")
ActiveForm = Form2;
else
ActiveForm = Form1;
}
// </Snippet2>
public bool isAccessKey(MobileCapabilities caps,
string optValue)
{
// Determine if the browser is not a Web crawler
// and can use access keys
if (!caps.Crawler && caps.SupportsAccesskeyAttribute)
return true;
return false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form runat="server" id="Form1" >
<mobile:Label 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="Label1" runat="server" />
</mobile:Form>
<mobile:Form ID="Form2" Runat="server">
<mobile:Label 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>
<%@ 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">
' <Snippet2>
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
' </Snippet2>
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>
注解
最初呈现页面时,该页中的第一个窗体将自动处于活动状态。 在后续回发时,可能通过编程方式设置此属性或用户通过控件进行导航,使另一个 Link 窗体处于活动状态。