ערוך

שתף באמצעות


WizardStepBase.AllowReturn Property

Definition

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

Property Value

true if the user is allowed to return to the current step; otherwise, false. The default value is true.

Attributes

Examples

The 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. In the example, the Step1 step has its AllowReturn property set to false. After 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>

Remarks

The AllowReturn property can be used to enforce linear navigation in a Wizard control. 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. By setting the AllowReturn property to false, once the user has left a step, they won't be able to return to it and change any values.

The AllowReturn property determines how and when the Previous button is not rendered. The following table describes the Previous button rendering behavior.

Scenario Behavior
Linear: Step1 has AllowReturn set to false and user action goes to step 2. Step 2 does not display the Previous button.
Non-Linear: Step1 has AllowReturn set to false and user action goes to step 3. Step 3 does not display the Previous button.
SideBar Buttons: Step 2 has AllowReturn set to false , DisplaySideBar is set to true, and a user clicks on the SideBar button. No 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. 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.
Using the Visual Studio Designer and ActiveStepIndex : The control has 5 steps, you are working on step 4, and you run the page. When step 4 is the ActiveStepIndex, then the Previous button is rendered. The Previous button is only hidden for StepType set to Step when the preceding step in the history has AllowReturn set to false. Since step 4 is rendered first and there are no steps in the history, the Previous button is not hidden.
Start Step and Non-Linear Navigation: A user visits step 3 and step 4 and then step 1 which has StepType set to Start. The wizard does not add a Previous button when the StepType is set to Start regardless of how the user navigates to that step.
Same Step In History: A user visits step 3 where StepType is set to Step and the user does not commit their actions. They then click on the previous button on step 3. The wizard control checks to see if the Previous step in the history is the "same" step that the user is currently on. 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.

Note

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. The 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. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

Applies to

See also