user158017
user158017

Reputation: 2991

Asp.net Wizard control e.cancel not working

UPDATE: in the below, if I change "asp:ListView " to "asp:DataList" the e.cancel works just fine, but then the layout is back in the traditional table format instead of divs.


I have had an asp.net (.Net 4.0) Wizard control functioning for over a year in production using the default setup. The next and previous buttons run validations and call e.cancel=true in case of failed validations. The side bar calls either the next or previous button as appropriate.

In our new version I am moving away from the default mode which generates tables and am using the LayoutTemplates. Now the next and previous buttons still work perfectly, but the sidebar buttons don't. All the methods get called and the variables get set appropriately as before, but when e.cancel is reached it doesn't cancel the navigation. I have even tried setting a variable that will then allow e.cancel to be used in the sidebar method itself instead of using the next/previous ones. It still doesn't work.

Below are the relevant samples:

--markup

            <div id="wizardStepSection"><asp:PlaceHolder ID="WizardStepPlaceHolder" runat="server" /></div>

                 <div id="wizardNavigationSection"><asp:PlaceHolder ID="navigationPlaceHolder" runat="server" /></div>

             </div>            

             <div id="wizardSideBarSection"><asp:PlaceHolder ID="sideBarPlaceHolder" runat="server" /></div>

             <div style="clear: both"></div>

         </div>

      </LayoutTemplate>

        <asp:ListView ID="sideBarList" runat="server">
            <ItemTemplate>
             <div class="inactiveSidebar">
             <asp:LinkButton ID="SideBarButton" runat="server" Text="Button" /></div>
          </ItemTemplate>

            <SelectedItemTemplate>
                <div class="activeSidebar">
                    <asp:LinkButton ID="SideBarButton" runat="server" Text="Button" />
                </div>
      </SelectedItemTemplate>
        </asp:ListView>
    </SideBarTemplate>

--side bar button Private Sub VRAWizard_SideBarButtonClick(sender As Object, e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles VRAWizard.SideBarButtonClick

        If e.CurrentStepIndex < e.NextStepIndex Then    
            VRAWizard_NextButtonClick(sender, e)                 

        Else    
            VRAWizard_PreviousButtonClick(sender, e)    
        End If



        If Me.cancelleavingstep Then    
            e.Cancel = True    
        End If

    End Sub

--Previous Button

Private Sub VRAWizard_PreviousButtonClick(sender As Object, e As   System.Web.UI.WebControls.WizardNavigationEventArgs) Handles VRAWizard.PreviousButtonClick

        Select Case validateStep(Me.VRAWizard.WizardSteps.Item(e.CurrentStepIndex).ID)

            Case False    
                Me.cancelleavingstep = True    
                e.Cancel = True    
        End Select

    End Sub

Upvotes: 1

Views: 512

Answers (1)

user158017
user158017

Reputation: 2991

Figured it out! I was making it way too hard on myself.

Instead of asp:ListView I needed to keep asp:DataList. Then, add the attribute: RepeatLayout="Flow". Done! e.cancel works and the layout is in spans.

MSDN documentation for datalist

Upvotes: 0

Related Questions