Wizard.OnActiveStepChanged(Object, EventArgs) 方法

定义

引发 ActiveStepChanged 事件。

protected:
 virtual void OnActiveStepChanged(System::Object ^ source, EventArgs ^ e);
protected virtual void OnActiveStepChanged (object source, EventArgs e);
abstract member OnActiveStepChanged : obj * EventArgs -> unit
override this.OnActiveStepChanged : obj * EventArgs -> unit
Protected Overridable Sub OnActiveStepChanged (source As Object, e As EventArgs)

参数

source
Object

事件源。

e
EventArgs

包含事件数据的 EventArgs

示例

下面的代码示例演示如何使用 ActiveStepChanged 事件更新 HeaderText 控件的 Wizard 属性。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  void OnActiveStepChanged(object sender, EventArgs e)
  {
    // Every time that the ActiveStep property changes, change the HeaderText to match it.
    Wizard1.HeaderText = "You are currently on " + Wizard1.ActiveStep.Title;
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
      <form id="form1" runat="server">
        <asp:Wizard ID="Wizard1" 
          Runat="server" 
          OnActiveStepChanged="OnActiveStepChanged" 
          HeaderText="ActiveStepChanged Example">
          <WizardSteps>
            <asp:WizardStep Title="Step 1" 
              Runat="server">
            </asp:WizardStep>
            <asp:WizardStep Title="Step 2" 
              Runat="server">
            </asp:WizardStep>
          </WizardSteps>
        </asp:Wizard>
      </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  Sub OnActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    
    ' Every time that the ActiveStep property changes, change the HeaderText to match it.
    Wizard1.HeaderText = "You are currently on " + Wizard1.ActiveStep.Title
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
      <form id="form1" runat="server">
        <asp:Wizard ID="Wizard1" 
          Runat="server" 
          OnActiveStepChanged="OnActiveStepChanged" 
          HeaderText="ActiveStepChanged Example">
          <WizardSteps>
            <asp:WizardStep ID="WizardStep1" Title="Step 1" 
              Runat="server">
            </asp:WizardStep>
            <asp:WizardStep ID="WizardStep2" Title="Step 2" 
              Runat="server">
            </asp:WizardStep>
          </WizardSteps>
        </asp:Wizard>
      </form>
  </body>
</html>

注解

OnActiveStepChanged 控件的 ActiveStepChanged 属性发生更改时, ActiveStepWizard 方法将引发 事件。 当 ActiveStepChanged 控件中显示的 Wizard 当前步骤发生更改时,使用 事件提供其他处理。

引发事件时,将通过委托调用事件处理程序。 有关详细信息,请参阅 处理和引发事件

OnActiveStepChanged 方法还允许派生类对事件进行处理而不必附加委托。 这是在派生类中处理事件的首选技术。

继承者说明

在派生类中重写 OnActiveStepChanged(Object, EventArgs) 方法时,请务必调用 OnActiveStepChanged(Object, EventArgs) 基类的 方法,以便注册的委托接收事件。

适用于

另请参阅