如何在 ASP.NET 应用程序中使用 jQuery 捕获提交事件? [英] How to capture submit event using jQuery in an ASP.NET application?
本文介绍了如何在 ASP.NET 应用程序中使用 jQuery 捕获提交事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 jQuery 处理 form
元素的 submit
事件.
$("form").bind("submit", function() {alert("您正在提交!");});
这在表单提交时永远不会触发(作为回发的一部分,例如当我点击按钮或链接按钮时).
有没有办法让这个工作?我可以附加到触发提交的单个元素的事件,但这不太理想 - 有太多的可能性(例如带有 autopostback=true 的下拉列表、键盘快捷键等)
<小时>更新:这是一个最小的测试用例 - 这是我的 aspx 页面的全部内容:
<%@ page language="vb" autoeventwireup="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="服务器"><title></title>头部><身体><form id="form1" runat="server"><div><asp:scriptmanager id="ScriptManager" runat="server" enablepartialrendering="true"><脚本><asp:scriptreference path="/Standard/Core/Javascript/Jquery.min.js"/></脚本></asp:scriptmanager><p><asp:linkbutton id="TestButton" text="点击我!"runat="服务器"/></p>
</表单><script type="text/javascript">$(document).ready(function() {alert("文件准备好了.");$("form").submit(function() {alert("检测到提交.");});});