Wizard.OnPreviousButtonClick(WizardNavigationEventArgs) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
引發 PreviousButtonClick 事件。
protected:
virtual void OnPreviousButtonClick(System::Web::UI::WebControls::WizardNavigationEventArgs ^ e);
protected virtual void OnPreviousButtonClick (System.Web.UI.WebControls.WizardNavigationEventArgs e);
abstract member OnPreviousButtonClick : System.Web.UI.WebControls.WizardNavigationEventArgs -> unit
override this.OnPreviousButtonClick : System.Web.UI.WebControls.WizardNavigationEventArgs -> unit
Protected Overridable Sub OnPreviousButtonClick (e As WizardNavigationEventArgs)
參數
範例
下列程式代碼範例示範如何指定事件的事件處理程式 PreviousButtonClick 。 每次按兩下 [ 上一步 ] 按鈕時, BorderWidth 控件的 屬性 Wizard 會隨著 類別測量 Unit 而減少1圖元。
<%@ 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 OnNextButtonClick(object sender, WizardNavigationEventArgs e)
{
// When the Next button is clicked, increase the
// Wizard1.BorderWidth by 1.
Wizard1.BorderWidth = Unit.Pixel((int)(Wizard1.BorderWidth.Value + 1));
}
void OnPreviousButtonClick(object sender, WizardNavigationEventArgs e)
{
// When the Previous button is clicked, decrease the
// Wizard1.BorderWidth by 1.
Wizard1.BorderWidth = Unit.Pixel((int)(Wizard1.BorderWidth.Value - 1));
}
</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"
onnextbuttonclick="OnNextButtonClick"
onpreviousbuttonclick="OnPreviousButtonClick"
borderstyle="Solid"
bordercolor="#3300ff"
borderwidth="1">
<WizardSteps>
<asp:WizardStep id="WizardStep1"
runat="server"
title="Step 1">
</asp:WizardStep>
<asp:WizardStep id="WizardStep2"
runat="server"
title="Step 2">
</asp:WizardStep>
<asp:WizardStep id="WizardStep3"
runat="server"
title="Step 3">
</asp:WizardStep>
<asp:WizardStep id="WizardStep4"
runat="server"
title="Step 4">
</asp:WizardStep>
<asp:WizardStep id="WizardStep5"
runat="server"
title="Step 5">
</asp:WizardStep>
<asp:WizardStep id="WizardStep6"
runat="server"
title="Step 6">
</asp:WizardStep>
<asp:WizardStep id="WizardStep7"
runat="server"
title="Step 7">
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>NextButtonClick and PreviousButtonClick Example</b>
</HeaderTemplate>
</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 OnNextButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
' When the Next button is clicked, increase the
' Wizard1.BorderWidth by 1.
Wizard1.BorderWidth = Unit.Pixel(CInt(Wizard1.BorderWidth.Value + 1))
End Sub
Sub OnPreviousButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
' When the Previous button is clicked, decrease the
' Wizard1.BorderWidth by 1.
Wizard1.BorderWidth = Unit.Pixel(CInt(Wizard1.BorderWidth.Value - 1))
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"
onnextbuttonclick="OnNextButtonClick"
onpreviousbuttonclick="OnPreviousButtonClick"
borderstyle="Solid"
bordercolor="#3300ff"
borderwidth="1">
<WizardSteps>
<asp:WizardStep id="WizardStep1"
runat="server"
title="Step 1">
</asp:WizardStep>
<asp:WizardStep id="WizardStep2"
runat="server"
title="Step 2">
</asp:WizardStep>
<asp:WizardStep id="WizardStep3"
runat="server"
title="Step 3">
</asp:WizardStep>
<asp:WizardStep id="WizardStep4"
runat="server"
title="Step 4">
</asp:WizardStep>
<asp:WizardStep id="WizardStep5"
runat="server"
title="Step 5">
</asp:WizardStep>
<asp:WizardStep id="WizardStep6"
runat="server"
title="Step 6">
</asp:WizardStep>
<asp:WizardStep id="WizardStep7"
runat="server"
title="Step 7">
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>NextButtonClick and PreviousButtonClick Example</b>
</HeaderTemplate>
</asp:Wizard>
</form>
</body>
</html>
備註
PreviousButtonClick按兩下 [上一步] 按鈕時,就會引發事件。
引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱 處理和引發事件。
OnPreviousButtonClick 方法也允許衍生類別處理事件,而不用附加委派。 這是在衍生類別中處理事件的慣用技巧。
給繼承者的注意事項
在衍生類別中覆 OnPreviousButtonClick(WizardNavigationEventArgs) 寫 方法時,請務必呼叫 OnPreviousButtonClick(WizardNavigationEventArgs) 基類的方法,讓已註冊的委派接收事件。