【发布时间】:2016-07-17 18:02:52
【问题描述】:
我的应用程序中有一个 asp.net 向导控件。我无法解释我所看到的行为,但这就是它正在做的事情。
向导从用户那里收集数据,在向导第一步的底部,我有一个免责声明,说明用户同意条款和条件,并带有一个表示他们同意的复选框。我没有将所有术语都放在向导中,而是在另一个 aspx 页面中详细说明了所有这些。在向导中,我有一个声明,上面写着“我-您的名字-同意条款和条件。”条款和条件是一个 asp 链接按钮,它执行跨页回发到我的其他页面,并在新窗口/标签中打开。
当您单击“继续”按钮前进到向导的第二步时,事情变得疯狂。如果用户没有单击 LinkButton 来查看条款,那么一切正常 - 数据表单得到验证,向导继续下一步。但是,如果他们单击“条款和条件”链接按钮,它将返回到我的条款页面,并在该页面上显示带有输入名称的条款 - 应该如此。这是我无法解释的部分......当他们返回向导并单击“继续”按钮时,它会打开另一个条款和条件选项卡,并且不会进入下一个向导步骤。
这就像单击 LinkButton 控件以某种方式重新连接向导的下一步按钮应该执行的操作。但只有在单击 LinkButton 时才会发生这种情况。
这是我的向导声明...
<asp:Wizard ID="Wizard1" runat="server" CellSpacing="5" Font-Names="Verdana" DisplaySideBar="False"
ActiveStepIndex="0" FinishCompleteButtonText="Submit" StartNextButtonText="Continue" Width="100%" OnNextButtonClick="Wizard1_NextButtonClick" OnFinishButtonClick="Wizard1_FinishButtonClick" ValidateRequestMode="Enabled">
<StartNavigationTemplate>
<asp:Button ID="StartNextButton" CausesValidation="true" runat="server" BackColor="White" BorderColor="#091C49" BorderStyle="Solid" BorderWidth="1px" CommandName="MoveNext" Font-Names="Verdana" Text="Continue" UseSubmitBehavior="False" />
</StartNavigationTemplate>
<StepNavigationTemplate>
<asp:Button ID="StepPreviousButton" runat="server" BackColor="White" BorderColor="#091C49" BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="MovePrevious" Font-Names="Verdana" Text="Previous" />
<asp:Button ID="StepNextButton" runat="server" BackColor="White" BorderColor="#091C49" BorderStyle="Solid" BorderWidth="1px" CommandName="MoveNext" Font-Names="Verdana" Text="Next" />
</StepNavigationTemplate>
<StepStyle VerticalAlign="Top" />
<SideBarStyle BackColor="#507CD1" Height="100%" HorizontalAlign="Left"
VerticalAlign="Top" Width="140px" />
<NavigationButtonStyle BackColor="White" BorderColor="#091c49" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" />
这是第一个向导步骤底部的复选框和链接按钮。
<asp:CheckBox ID="cbSignature" runat="server" Checked="false" OnClick="ShowHideCVText()" />
<asp:CustomValidator runat="server" ID="cvCheckBoxRequired" EnableClientScript="true" Font-Bold="true" OnServerValidate="CheckBoxRequired_ServerValidate" ClientValidationFunction="ValidateCheckBox" ErrorMessage="You must indicate that you have read and agree to the terms and conditions of this lease by checking the chekcbox below to continue." ForeColor="Red">*</asp:CustomValidator>
I <asp:Label ID="lblSignatureName" runat="server" /> have read and fully understand the <asp:LinkButton ID="lbLeaseTerms2" runat="server" OnClientClick="window.document.forms[0].target='_blank';" CausesValidation="false" PostBackUrl="~/LeaseAgreement" Text="Terms & Conditions" /> of the lease agreement between blah blah blah...
这可能与我用来使 LinkButton 在新窗口中打开的技巧有关吗?似乎不太可能,因为它在单独的控件上,但我不知道。
OnClientClick="window.document.forms[0].target='_blank';"
这是从第 1 步到第 2 步时代码后面发生的唯一事情...只是用输入的文本值填充一些标签控件。
protected void Wizard1_NextButtonClick(object sender, System.Web.UI.WebControls.WizardNavigationEventArgs e)
{
lblCustomersName.Text = txtFirstName.Text + " " + txtLastName.Text;
lblCustomersPhone.Text = txtPhoneNumber.Text;
lblPhoneType.Text = rblPhoneType.SelectedItem.Text;
lblCustomerStreetAddress.Text = txtStreetAddress.Text + Environment.NewLine +
txtCity.Text + ", " + ddlState.SelectedItem.Text + " " + txtZip.Text;
lblCustomersEmail.Text = txtEmailAddress.Text;
lblParkingLength.Text = ddlLengthNeeded.SelectedItem.Text;
lblVehicleYear.Text = txtVehicleYear.Text;
lblRegisteredOwner.Text = txtRegisteredOwner.Text;
lblVehicleMake.Text = txtVehicleMake.Text;
//lblVehicleLicensePlate.Text = txtLicensePlate.Text;
lblLeaseDuration.Text = ddlLeaseDuration.SelectedItem.Text;
lblSummarySignature.Text = txtFirstName.Text + " " + txtLastName.Text;
}
在这一点上完全混淆了为什么单击的链接按钮会改变向导的继续按钮的行为。
【问题讨论】: