【问题标题】:Error While binding wizard绑定向导时出错
【发布时间】:2016-06-13 15:24:57
【问题描述】:

下面是向导代码。

<asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="false" OnNextButtonClick="Wizard1_NextButtonClick"
    CssClass="" OnFinishButtonClick="Wizard1_FinishButtonClick" FinishCompleteButtonText="Publish" OnLoad="Wizard1_Load" OnInit="Wizard1_Init"
    OnPreviousButtonClick="Wizard1_PreviousButtonClick" Width="100%" ActiveStepIndex="-1"  EnableViewState="false" > <%--OnLoad="Wizard1_Load" OnInit="Wizard1_Init"--%>
        <WizardSteps>
        <asp:WizardStep ID="wzsKeyData" runat="server" Title="KeyData">
            <div class="bidpost" style="padding-bottom:80px;">
                <asp:PlaceHolder ID="phKeyData" runat="server"></asp:PlaceHolder>
            </div>
        </asp:WizardStep>
        <asp:WizardStep ID="wzsTechnical" runat="server" Title="Technical">
            <div class="bidpost" style="padding-bottom:80px;">
                <asp:PlaceHolder ID="phTechSpecification" runat="server"></asp:PlaceHolder>
            </div>
        </asp:WizardStep>
        <asp:WizardStep ID="wzsCommercial" runat="server" Title="Commercial">
            <div class="bidpost" style="padding-bottom:135px;">
            <div class="row-fluid" style="text-align:left;font-weight:bold;">
                    <div class="span2">
                    <asp:Label ID="lblBidQuote" runat="server" Text="Bid Quote"></asp:Label>
                    </div>
                    <div class="span4">
                    <asp:TextBox ID="txtBidQuote" runat="server" PlaceHolder="E.g. 45678" CssClass="inputMargin" MaxLength="10" style="width:180px;"></asp:TextBox>
                        <cc1:FilteredTextBoxExtender ID="ftxtBidQuote" runat="server" Enabled="True" TargetControlID="txtBidQuote"
                            ValidChars="0123456789">
                    </cc1:FilteredTextBoxExtender>

                    <asp:RequiredFieldValidator runat="server" ID="rfvtxtBidQuote" ControlToValidate="txtBidQuote" InitialValue=""
                                ValidationGroup="validatebid" ForeColor="Red" Display="Dynamic" ErrorMessage="Please Enter Bid Quote!" />
                    </div>
                    <div class="span2 inputMargin">                                                                                
                    <asp:Label ID="lblDeliveryDate" runat="server" Text="Delivery Date"></asp:Label>
                    </div>
                    <div class="span4">
                    <asp:TextBox ID="txtDeliveryDate" placeholder="E.g. February 18, 2016" CssClass="textBox spaninner datepickr" runat="server"> </asp:TextBox>
                                <i class=" fa fa-calendar calendar-icon calendar-icondeliverydate" style="top:-7px;"></i>
                    <asp:RequiredFieldValidator runat="server" ID="rfvtxtDeliveryDate" ControlToValidate="txtDeliveryDate" InitialValue=""
                                ValidationGroup="validatebid" ForeColor="Red" Display="Dynamic" ErrorMessage="Please Enter Delivery Date!" />
                    </div>
                </div>   

                <asp:PlaceHolder ID="phCommercial" runat="server"></asp:PlaceHolder>

            </div>
        </asp:WizardStep>
        <asp:WizardStep ID="wzsStatutory" runat="server" Title="Statutory">
            <div class="bidpost" style="padding-bottom:80px;">
                <asp:PlaceHolder ID="phStatutory" runat="server"></asp:PlaceHolder>
            </div>
        </asp:WizardStep>
        <asp:WizardStep ID="wzsOthers" runat="server" Title="Others">
            <div class="bidpost" style="padding-bottom:80px;">
                <asp:PlaceHolder ID="phOtherTerms" runat="server"></asp:PlaceHolder>
            </div>
        </asp:WizardStep>
    </WizardSteps>
    <HeaderTemplate>
        <ul id="wizHeader" class="bidpostwizheader">
            <asp:Repeater ID="SideBarList" runat="server">
                <ItemTemplate>
                    <li><a class="<%# GetClassForWizardStep(Container.DataItem) %>" title="<%#Eval("Name")%>">
                        <%# Eval("Name")%></a> </li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </HeaderTemplate>
    <StartNavigationTemplate>
        <div class="wizardbottomdiv">
            <asp:Button ID="StartNextButton" runat="server" CssClass="buttonNext" CommandName="MoveNext"
                Text="Next" />
        </div>
    </StartNavigationTemplate>
    <StepNavigationTemplate>
        <div class="wizardbottomdiv">
            <asp:Button ID="StepNextButton" runat="server" CssClass="buttonNext" CommandName="MoveNext"
                Text="Next" />
            <asp:Button ID="StepPreviousButton" runat="server" CssClass="buttonPrevious" CommandName="MovePrevious"
                Text="Previous" />
        </div>
    </StepNavigationTemplate>
    <FinishNavigationTemplate>
        <div class="wizardbottomdiv">
            <asp:Button ID="StepNextButton" runat="server" CssClass="buttonNext" CommandName="MoveComplete"
                Text="Save Response" />
            <asp:Button ID="StepPreviousButton" runat="server" CssClass="buttonPrevious" CommandName="MovePrevious"
                Text="Previous" />
        </div>
    </FinishNavigationTemplate>
</asp:Wizard>

在此页面中,我显示了服务列表和与之相关的部分。因此,当用户单击服务时,向导会显示该服务的所有部分。 最初有 5 个固定步骤,但现在除了这五个步骤之外,我还必须从 db 添加步骤,它确实添加了这些步骤。

现在的问题。假设如果服务有超过 5 个部分(6-7)而不是在这种情况下,这些部分(6th 和 7th)将从后面的代码中添加。所以当用户到达第 6 或第 7 部分并点击再次在服务上,而不是再次填充向导,什么也没有发生。在浏览器控制台中,它显示活动视图索引超出范围的错误。当前视图索引为 5,大于项目计数。

我几乎尝试了所有方法。在 aspx 页面、page_init、Page_preinit、Page_preload、Page_load、Serviceclick 事件中设置 activestepindex=0。 从代码后面添加wizardsteps - 在这种情况下,我保持向导的结构(标题模板和导航模板)不变,并从aspx页面中删除了所有这5个固定步骤。然后在服务名称上单击我从后面的代码中添加所有这些步骤。我还尝试在 page_init、Page_preinit、page_load 中调用此函数,因为错误建议在 page_preinit 中绑定视图。在绑定之前,我确保活动步骤索引设置为 0 或如果项目数更大,则设置为旧索引比索引。

我猜想在渲染之前再次加载控件视图状态的索引。我也尝试将此向导的 EnableViewstate 设置为 false,但即使这样也不起作用。

【问题讨论】:

    标签: c# asp.net wizard multiview


    【解决方案1】:

    我们找不到解决方案,所以我们用文字和 div 替换了向导,因为向导不能正常工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-01
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-23
      相关资源
      最近更新 更多