Javascript 未在asp.net组件上激活单击jQuery处理程序
我正在用jQuery开发一个C#/Asp应用程序 我希望在每次单击具有“LoadingProgress”类的组件时调用一个特定函数。然而,下面的代码似乎不起作用,我不知道为什么。我尝试过使用ID,使用CssClass而不是class,并使用Javascript 未在asp.net组件上激活单击jQuery处理程序,javascript,c#,jquery,asp.net,loader,Javascript,C#,Jquery,Asp.net,Loader,我正在用jQuery开发一个C#/Asp应用程序 我希望在每次单击具有“LoadingProgress”类的组件时调用一个特定函数。然而,下面的代码似乎不起作用,我不知道为什么。我尝试过使用ID,使用CssClass而不是class,并使用.click()而不是.on('click',…)都没有用 这是按钮代码 <asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" class="loadingInProg
.click()
而不是.on('click',…)
都没有用
这是按钮代码
<asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" class="loadingInProgress"
OnClick="btn_Rechercher_Click" />
嗯,您似乎还没有尝试过客户端单击
asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" class="loadingInProgress"
OnClick="btn_Rechercher_Click"
OnClientClick="loadingInProgress"/>
function loadingInProggress() {
displayOverlayInProgress(); // don't wait for ajaxStart
$(document).ajaxComplete(function (event, xhr, settings) {
removeOverlayInProgress();
});
}
试试这个
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
试试这个:
<asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" CssClass="loadingInProgress"
OnClick="btn_Rechercher_Click" />
问题是每次单击按钮时都不应运行
.ajaxStart
和.ajaxComplete
。
您应该在
.ready
上实现这两个回调,但在中单击事件,您应该只调用.ajax
,。load
,。get
或任何其他将启动请求的方法谢谢您的回答。看起来您的解决方案不会在流程开始时冻结网页,而只是在服务器应答时冻结。我需要一直冻结网页process@BarryF我认为直接调用displayOverlayProgress()
函数可以满足您的需要。我已经更新了答案。谢谢你的回答。谢谢你的回答,但我以前尝试过,但没有成功
<asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" class="loadingInProgress"
OnClick="btn_Rechercher_Click" />
$("#btn_Rechercher").click(function () {
$(document).ajaxStart(function () {
displayOverlayInProgress();
});
$(document).ajaxComplete(function (event, xhr, settings) {
removeOverlayInProgress();
});
});
<asp:Button ID="btn_Rechercher" Text="Rechercher" runat="server" CssClass="loadingInProgress"
OnClick="btn_Rechercher_Click" />