ASP.NET的LinkBut​​ton / ImageButton的和JQuery验证? [英] ASP.NET LinkButton / ImageButton and JQuery Validate?

查看:113
本文介绍了ASP.NET的LinkBut​​ton / ImageButton的和JQuery验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前推出的 JQuery的以现有的ASP.NET应用程序和使用验证插件的jQuery做客户端验证(我们不想用ASP .NET验证)。

Button控件:

一切与ASP很好地工作。提交页面之前的客户端验证被触发。

然而,当使用的LinkBut​​ton 的ImageButton 控制的页面没有得到验证先的形式提交。

这是由于验证工作与呈现为按钮事实的输入类型=提交而ImageButton的呈现为输入类型=形象

任何人都经历过这样?

非常感谢你的想法和相关信息如何解决。

更新:

非常感谢,您的回答有助于确定问题。
事实证明,有一个在验证​​的jQuery插件的错误。我们用一个补丁,以避免隐藏的输入字段的验证,它使用的家长()过滤器(:隐藏)。。这并不在的JQuery 1.3.2 正常工作。我们与。是(:可见),取代了它。现在,asp.net ImageButton的工作原理是默认!

UPDATE2

LinkBut​​ton的仍然没有工作。简单的解决方法是添加返回false点击功能,如果表单是无效的:

  $(#<%= tb.ClientID%GT;)。点击(函数(){
            返回$('形式')有效的()。
        })


解决方案

第一个建议可能仍然工作,因为你可能会导致回发的验证发生后使用Javascript火。

在JavaScript是:

  __ doPostBack('<%= YourImageControl.UniqueID%GT;','');

第二个空参数可用于传递参数。

We are introducing JQuery to an existing ASP.NET application and use the Validate plugin for JQuery to do the client side validation (we do not want to use the asp.net validators).

Everything works nicely with the asp:Button control. The client side validation is triggered before the page is submitted.

However when using the LinkButton and ImageButton controls the page gets submitted without validating the form first.

This is due to the fact that validate works with Buttons that are rendered as Input type="submit" while the ImageButton renders as Input type="image".

Anyone else experienced this?

Thanks a lot for ideas and infos how to resolve.

Update:

Thanks a lot, your answers helped to identify the problem. it turns out that there was a bug in the validate plugin for JQuery. We used a patch to avoid the validation of hidden input fields, which uses parents().filter(":hidden"). This doesn't work properly in JQuery 1.3.2. We replaced it with .is(":visible"). Now the asp.net ImageButton works by default!

Update2:

The LinkButton still did not work. The simple solution is to add a click function that returns false if the form is not valid:

$("#<%= tb.ClientID %>").click(function() {
            return $('form').valid();
        })

解决方案

The first suggestion might still work because you can cause the postback to fire using Javascript after the validation occurs.

The javascript is:

__doPostBack('<%= YourImageControl.UniqueID %>','');

The second empty parameter can be used to pass arguments.

这篇关于ASP.NET的LinkBut​​ton / ImageButton的和JQuery验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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