我在两个不同的ajax updatepanel中有一个包含两个用户控件的页面。一个控件有文本框,其他控件有一个按钮。我已将相同的验证组设置为用户控件的控件。当我点击按钮时,客户端验证会触发,但验证结束后会有一个反叛。
我已设置验证组,如下所示:
public string ValidationGroup
{
get
{
return txtFirstName.ValidationGroup;
}
set
{
txtFirstName.ValidationGroup = value;
txtLastName.ValidationGroup = value;
txtPhoneNumber.ValidationGroup = value;
txtEmail.ValidationGroup = value;
txtFaxNumber.ValidationGroup = value;
txtCompany.ValidationGroup = value;
txtAddress1.ValidationGroup = value;
txtAddress2.ValidationGroup = value;
txtCity.ValidationGroup = value;
txtZipPostalCode.ValidationGroup = value;
}
}
and here is how first control is user with validation group set to that property:
<nopCommerce:AddressEdit ID="ctrlBillingAddress" runat="server" IsNew="true" IsBillingAddress="true"
ValidationGroup="CheckoutConfirm" />
and here is how the control with button looks like:
<nopCommerce:CheckoutConfirm ID="ctrlCheckoutConfirm" runat="server" OnePageCheckout="true"
OnCheckoutStepChanged="ctrlCheckoutConfirm_CheckoutStepChanged" />
where as markup for the button is like this:
<asp:LinkButton runat="server" ID="btnNextStep"
OnClick="btnNextStep_Click" ValidationGroup="CheckoutConfirm" CausesValidation="true"><img src="App_Themes/darkOrange/images/btnPlaceOrder.png" alt="Place Order" /></asp:LinkButton>
请建议如何在没有回发的情况下进行客户端验证?
答案 0 :(得分:1)
你可以使用javascript写这篇文章:
function check(){
if (Page_ClientValidate('validationgroup')) {
return true;
}
else {
return false;
}
}
同时尝试在chrome中调试完整代码可能也会在某些行中出现错误。
答案 1 :(得分:0)
更新面板上的updatemode设置为什么?
请参阅asp.net论坛上的this post。这可能会对你有帮助。