views:

361

answers:

1

I'm trying to make the SideBar function more like Prev/Next buttons. The navigation buttons only check for validation when moving forward; they don't care if you go back. As far as I can tell, you can only have one or the other option on the SideBar, not both. So, here's what I was attempting to do:

<SideBarTemplate>
  <asp:DataList ID="SideBarList"  runat="server">
    <ItemTemplate>
      <asp:LinkButton ID="SideBarButton" runat="server" CausesValidation="<%# Container.ItemIndex >= myWizard.ActiveStepIndex %>" />
   </ItemTemplate>
  </asp:DataList>
</SideBarTemplate>

It works going forward, but fails on previous steps with this error:

Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate.

Any suggestions?

edit: I did take a look at this post, but it doesn't appear to solve the problem.

A: 

I've ran into a similar issue when I started using StartNavigationTemplate, StepNavigationTemplate and FinishNavigationTemplate. My solution for the StepNavigation was to put the following snippet:

    protected void wiz_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
         if (e.CurrentStepIndex > 0 && Page.IsValid)
         {...

I suspect it's because there's nothing to validate on my first page.

However, I still have the problem when my OnFinishButtonClick is called, and I can't find any way of getting around it so far.

furtive