2009-09-03 33 views
0

我想让SideBar函数更像Prev/Next按钮。导航按钮仅在向前移动时检查验证;他们不在乎你是否回去。据我所知,你只能在SideBar上有一个或另一个选项,而不是两个。所以,在这里就是我一直试图做的事:asp:向导SideBarTemplate - 动态CausesValidation导致Page.IsValid错误

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

它工作向前发展,但与此错误失败,以前的步骤:

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.

有什么建议?

编辑:我确实看过this post,但它似乎没有解决问题。

回答

0

我开始使用StartNavigationTemplate,StepNavigationTemplate和FinishNavigationTemplate时遇到类似的问题。我对StepNavigation的解决办法是把下面的代码片段:

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

我怀疑这是因为没有什么来验证我的第一页上。

但是,我仍然有问题,当我的OnFinishButtonClick被调用,我找不到任何方式来解决它到目前为止。