WizardStepBase.AllowReturn 屬性

定義

取得或設定值,指出是否允許使用者從 WizardStepCollection 集合的後續步驟返回目前步驟。Gets or sets a value indicating whether the user is allowed to return to the current step from a subsequent step in a WizardStepCollection collection.

public:
 virtual property bool AllowReturn { bool get(); void set(bool value); };
[System.Web.UI.Themeable(false)]
public virtual bool AllowReturn { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.AllowReturn : bool with get, set
Public Overridable Property AllowReturn As Boolean

屬性值

Boolean

如果允許使用者返回目前步驟,則為 true,否則為 falsetrue if the user is allowed to return to the current step; otherwise, false. 預設值是 trueThe default value is true.

屬性

範例

下列範例將示範如何使用 AllowReturn 屬性,以防止使用者在存取之後返回控制項中的步驟 WizardThe following example demonstrates using the AllowReturn property to stop the user from returning to a step in the Wizard control after it has been accessed. 在此範例中, Step1 步驟已 AllowReturn 將其屬性設定為 falseIn the example, the Step1 step has its AllowReturn property set to false. 當使用者離開步驟之後 Step1 ,步驟上就不會出現 [上一個] 按鈕 Step2After the user leaves the Step1 step, no Previous button appears on the Step2 step.

<%@ 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">

</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"
    displaysidebar="false" >
        <WizardSteps>
          <asp:WizardStep id="WizardStep1" 
            title="Step 1" 
            allowreturn="false"
            runat="server">
            You are currently on Step 1.
          </asp:WizardStep>
          <asp:WizardStep id="WizardStep2" 
            title="Step 2" 
            runat="server">
            You are currently on Step 2.
          </asp:WizardStep>
          <asp:WizardStep id="WizardStep3" 
            title="Step 3" 
            runat="server">
            You are currently on Step 3.
          </asp:WizardStep>
        </WizardSteps>
        <HeaderTemplate>
          <b>WizardStepBase AllowReturn 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">

</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"
    displaysidebar="false" >
        <WizardSteps>
          <asp:WizardStep id="WizardStep1" 
            title="Step 1" 
            allowreturn="false"
            runat="server">
            You are currently on Step 1.
          </asp:WizardStep>
          <asp:WizardStep id="WizardStep2" 
            title="Step 2" 
            runat="server">
            You are currently on Step 2.
          </asp:WizardStep>
          <asp:WizardStep id="WizardStep3" 
            title="Step 3" 
            runat="server">
            You are currently on Step 3.
          </asp:WizardStep>
        </WizardSteps>
        <HeaderTemplate>
          <b>WizardStepBase AllowReturn Example</b>
        </HeaderTemplate>
      </asp:Wizard>
    </form>
  </body>
</html>

備註

AllowReturn屬性可以用來強制執行控制項中的線性導覽 WizardThe AllowReturn property can be used to enforce linear navigation in a Wizard control. 如果每個步驟 AllowReturn 將其屬性設定為 false ,則使用者在存取之後將無法返回步驟。If each step has its AllowReturn property set to false, the user will not be able to return to a step after it has been accessed. 您可以使用這項功能的其中一個情況是,不允許使用者在完成後返回步驟,因為每個步驟完成時,您會將資料保存到資料庫。One scenario where you might use this functionality is to disallow a user to return to a step after it has been completed because you are persisting the data to a database as each step is completed. 如果您在每個步驟之後儲存資料,並允許使用者返回步驟,並在儲存之後變更資訊,儲存的資料可能會損毀。If you save the data after each step and allow the user to return to a step and change information after it has been saved, the saved data might become corrupted. 藉由將 AllowReturn 屬性設定為 false ,當使用者離開某個步驟之後,他或她將無法返回該步驟,也無法變更任何值。By setting the AllowReturn property to false, once the user has left a step, he or she will not be able to return to it and change any values.

AllowReturn屬性會決定未轉譯 上一個 按鈕的方式和時間。The AllowReturn property determines how and when the Previous button is not rendered. 下表說明 上一個 按鈕轉譯行為。The following table describes the Previous button rendering behavior.

狀況Scenario 行為Behavior
線性:步驟1已 AllowReturn 設定為 false ,而使用者動作會移至步驟2。Linear: Step1 has AllowReturn set to false and user action goes to step 2. 步驟2不會顯示 [ 上一 步] 按鈕。Step 2 does not display the Previous button.
非線性:步驟1已 AllowReturn 設定為 false ,而使用者動作會移至步驟3。Non-Linear: Step1 has AllowReturn set to false and user action goes to step 3. 步驟3不會顯示 [ 上一 步] 按鈕。Step 3 does not display the Previous button.
提要欄位按鈕:步驟2的 AllowReturn 設定為 falseDisplaySideBar 設定為 true ,且使用者按一下提要欄位按鈕。SideBar Buttons: Step 2 has AllowReturn set to false , DisplaySideBar is set to true, and a user clicks on the SideBar button. 當設定為時,提要欄位上不會自動停用任何按鈕 AllowReturn falseNo buttons are automatically disabled on the sidebar when AllowReturn is set to false. 如果使用者按一下此按鈕,則會忽略該動作。If a user clicks the button, the action is ignored.
使用自訂範本的非線性 & 非線性:步驟有自訂流覽範本。Linear & Non-Linear with Custom Template: The step has a custom navigation template. AllowReturn false 當您使用範本進行導覽時,如果設為,則不會發生自動隱藏或顯示。No automatic hiding or displaying occurs if AllowReturn is set to false when you use a template for navigation. 在範本上,[ 上一步 ] 按鈕應該是選擇性的。The Previous button should be optional on the template.
使用 Visual Studio 設計工具和 ActiveStepIndex :控制項有5個步驟,您正在執行步驟4,而您執行的是頁面。Using the Visual Studio Designer and ActiveStepIndex : The control has 5 steps, you are working on step 4, and you run the page. 當步驟4為時 ActiveStepIndex ,就會轉譯 [ 上一個 ] 按鈕。When step 4 is the ActiveStepIndex, then the Previous button is rendered. 當歷程 StepType Step 記錄中的上一個步驟 AllowReturn 設定為時,才會隱藏 [上一個] 按鈕,設定為 falseThe Previous button is only hidden for StepType set to Step when the preceding step in the history has AllowReturn set to false. 因為步驟4是先轉譯的,且歷程記錄中沒有任何步驟,所以不會隱藏 [ 上一個 ] 按鈕。Since step 4 is rendered first and there are no steps in the history, the Previous button is not hidden.
開始步驟和非線性導覽:使用者造訪步驟3和步驟4,然後 StepType 將設定為的步驟 1 StartStart Step and Non-Linear Navigation: A user visits step 3 and step 4 and then step 1 which has StepType set to Start. 當設定為時, StepType Start 不論使用者如何流覽至該步驟,wizard 都不會加入 [上一個] 按鈕。The wizard does not add a Previous button when the StepType is set to Start regardless of how the user navigates to that step.
歷程記錄中的相同步驟:使用者造訪步驟3,其中 StepType 設定為 Step ,且使用者不會認可其動作。Same Step In History: A user visits step 3 where StepType is set to Step and the user does not commit their actions. 然後,他們會按一下步驟3上的 [上一步] 按鈕。They then click on the previous button on step 3. Wizard 控制項會檢查歷程記錄中的 上一個 步驟是否為使用者目前所在的「相同」步驟。The wizard control checks to see if the Previous step in the history is the "same" step that the user is currently on. 如果步驟相同,則 wizard 控制項會查看歷程記錄,以判斷之前的「不同」步驟,並根據歷程記錄中的「不同步驟」來建立 上一個 按鈕和目的地的顯示。If the step is the same, the wizard control looks back in the history to determine the preceding "different" step and bases the display of the Previous button and destination based on the "different step" in the history.

注意

AllowReturn 屬性設定為 false ,但的 DisplaySideBar 父控制項的屬性 WizardStepBase 設定為時 true ,按一下提要欄位區域中的按鈕沒有任何作用。When the AllowReturn property is set to false, but the DisplaySideBar property of the parent control of WizardStepBase is set to true, clicking on a button in the sidebar area has no effect. 通常會顯示提要欄位區域以提供非線性導覽,因此,如果您不使用非線性導覽的功能,您可能會想要將 DisplaySideBar 屬性設定為 falseThe sidebar area is generally displayed to provide nonlinear navigation, so if you are not using the functionality of nonlinear navigation, you may want to set the DisplaySideBar property to false.

這個屬性無法由佈景主題或樣式表主題設定。This property cannot be set by themes or style sheet themes. 如需詳細資訊,請參閱 ThemeableAttributeASP.NET 主題和外觀For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

適用於

另請參閱