Form.Activate 事件

定义

当激活窗体时发生。 此 API 已废弃不用。 有关如何开发 ASP.NET 移动应用程序的信息,请参阅 移动应用 & 具有 ASP.NET 的网站

public:
 event EventHandler ^ Activate;
public event EventHandler Activate;
member this.Activate : EventHandler 
Public Custom Event Activate As EventHandler 

事件类型

示例

下面的代码示例演示如何将 元素中的 OnActivateForm 属性设置为指向在事件发生时 Activate 执行的方法。 方法 Form2_Activate 准备要显示的第二个窗体。 此示例是概述的较大示例的 Form 一部分。

注意

下面的代码示例使用单文件代码模型,如果直接复制到代码隐藏文件中,可能无法正常工作。 此代码示例必须复制到扩展名为 .aspx 的空文本文件中。 有关详细信息,请参阅 ASP.NET Web Forms 页语法概述

// When Form2 is activated
private void Form2_Activate(object sender, EventArgs e)
{
    Form2.BackColor = Color.DarkGray;
    Form2.ForeColor = Color.White;
    Form2.Font.Bold = BooleanOption.True;
}
' When Form2 is activated
Private Sub Form2_Activate(ByVal sender As Object, _
    ByVal e As EventArgs)

    Form2.BackColor = Color.DarkGray
    Form2.ForeColor = Color.White
    Form2.Font.Bold = BooleanOption.True
End Sub
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<!-- The first Form -->
    <mobile:Form ID="Form1" Runat="server" 
        Paginate="true" OnActivate="Form_Activate" 
        OnPaginated="Form_Paginated">
        <mobile:link ID="Link1" Runat="server" 
            NavigateUrl="#Form2">
            Go To Other Form
        </mobile:link>
        <mobile:Label ID="Label1" Runat="server">
            Welcome to ASP.NET
        </mobile:Label>
        <mobile:textview ID="txtView" Runat="server" />
        
        <mobile:DeviceSpecific ID="DevSpec" Runat="server">
            <Choice>
                <FooterTemplate>
                    <mobile:Label runat="server" id="lblCount" />
                </FooterTemplate>
            </Choice>
        </mobile:DeviceSpecific>

    </mobile:Form>
    
    <!-- The second Form -->
    <mobile:Form ID="Form2" Runat="server" 
        Paginate="true" OnPaginated="Form_Paginated">
        <mobile:Label ID="message2" Runat="server">
            Welcome to ASP.NET
        </mobile:Label>
        <mobile:link ID="Link2" Runat="server" 
            NavigateUrl="#Form1">Back</mobile:link>
    </mobile:Form>
</body>
</html>

注解

事件发生 Activate 在以下情况下:

  • 首次请求页面时,将激活第一个窗体。

  • ActiveForm以编程方式设置页面的 属性时。

  • 当用户通过 Link 目标为窗体的控件导航到窗体时。

此事件在事件链中的位置使得将子控件绑定到数据源或设置可由所有子控件继承的窗体属性非常重要。

适用于

另请参阅