简体   繁体   English

单击并禁用asp.net按钮并显示加载图像

[英]Disabling asp.net button on click and show loading image

I am working on an asp.net page. 我正在asp.net页面上。 Page as a button which redirects user to another page using response.redirect. 页面作为按钮,使用response.redirect将用户重定向到另一个页面。 I want to disable the button and show a loading icon. 我想禁用该按钮并显示一个加载图标。

I used this jquery 我用这个jQuery的

$('.rbutton').on('click', function () {
$(this).prop("disabled", true);

It disables the button but then server side code is not fired. 它禁用该按钮,但是不会触发服务器端代码。

button is not surrounded with ajax update panel. 按钮没有被ajax更新面板包围。 I don't want to use ajax toolkit. 我不想使用ajax工具包。

How can I show loading image on click of search button and then disable the button until user is redirected to new page ? 如何在单击搜索按钮时显示加载图像,然后禁用该按钮,直到用户被重定向到新页面?

ASP.Net won't execute server code for a disabled button. ASP.Net不会为禁用的按钮执行服务器代码。 In the past, I've simply hidden the button and replaced it with another button that is disabled... has worked well for me. 过去,我只是隐藏了按钮,然后将其替换为另一个已禁用的按钮...对我来说效果很好。

<asp:Button ID="_pay" OnClick="SomeGreatCode" Text="Pay Up!" runat="server" />
<asp:Button ID="_process" Enabled="false" Text="Processing..." runat="server" />


<script>
$(document).ready(function () {
    $("#<%= _process.ClientID %>").hide();
    $('#<%= _pay.ClientID %>').on('click', function () {
        if (Page_IsValid) {
            $(this).hide();
            $("#<%= _process.ClientID %>").show();
        }
    });
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM