下拉式Autopostback在jQuery Validation错误上失败 [英] Dropdown Autopostback failing on jQuery Validation errors

查看:64
本文介绍了下拉式Autopostback在jQuery Validation错误上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们有一个SP2010网站,使用jquery validate插件进行验证。在自定义WebPart中,布局具有很少的公共字段,下拉列表和多个面板,这些面板根据下拉列表中选择的值加载。问题是如果有人点击保存并且有验证错误(必填字段)验证,则OnSelectedIndexChanged会停止触发。



Hi,

We have a SP2010 site where validation is done using the jquery validate plugin. In a custom WebPart the layout has few common fields, a dropdown and multiple panels which load based on the value selected in the dropdown. The issue is that in case someone clicks on save first and there are validation errors(required field) validation the OnSelectedIndexChanged stops firing.

<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged"></asp:DropDownList>





多个面板,每个面板都有一个保存和关闭按钮:



Multiple panels, each with a save and close button:

<asp:Button ID="btnSubmit1" runat="server" Text="Save" onclick="btnSubmit1_Click" />
<asp:Button ID="btnClose1" runat="server" CssClass="cancel" CausesValidation="false" Text="Close" onclick="btnClose1_Click" />





Script-jQuery验证:



Script- jQuery Validation:

$("form").validate({
        rules:{
	   REQUIRED VALIDATION RULES FOR MULTIPLE FIELDS
	}
    });





页面加载后,只要没有发生错误,下拉帖子就可以了,但是一旦出现验证错误,即使错误得到纠正后也是如此页面不会回发下拉列表的更改。



非常感谢任何帮助。



After the page load the dropdown posts back just fine as long as no errors have occurred but once there are validation errors then even after the errors are corrected the page does not post back on the change of dropdown.

Really appreciate any help on this.

推荐答案

(form)。validate({
规则:{
多个领域需要的验证规则
}
});
("form").validate({ rules:{ REQUIRED VALIDATION RULES FOR MULTIPLE FIELDS } });





页面加载后,只要没有发生错误,下拉列表就会恢复正常但是一旦出现验证错误,那么即使错误得到纠正,页面也不会回发下拉列表的更改。



非常感谢任何帮助。



After the page load the dropdown posts back just fine as long as no errors have occurred but once there are validation errors then even after the errors are corrected the page does not post back on the change of dropdown.

Really appreciate any help on this.






刚刚找到了客户端解决方案。如果我添加一个



Hi,

Just found a client-side solution. If I add a


('。dropdownclassname')。change(function(){面板更改的逻辑使用.show()和.hide()})
('.dropdownclassname').change(function(){ logic for panel change using .show() and .hide() })





函数在代码中不需要服务器侧回发。该解决方案的代码工作正常,更改事件正常启动。



function in the code there is no need for a server side postback. The code is working fine with this solution and the change event is firing properly.


这篇关于下拉式Autopostback在jQuery Validation错误上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆