在点击即时禁用按钮 [英] Instantly disable Button on click
问题描述
我想点击后立即禁用按钮,这样在短时间内连续用户不能点击两次,连续火OnClick_Event的两倍。 btn.Enabled = FALSE
似乎并没有立刻做的伎俩。是否有任何其他的方式来做到这一点?
I'd like to instantly disable a Button after clicking it, so a User can't click it twice in short succession and fire the OnClick_Event twice in a row. btn.Enabled = false
doesn't seem to do the trick instantly. Is there any other way to accomplish this?
谢谢,
丹尼斯
推荐答案
你在做什么回来了。所以,你们按钮的时候,浏览器收到的反应,呈现的页面被禁用后后关闭它。
What you are doing is disabling it after a post back therefore your button will be disabled in the page that's rendered when the browser receives the response.
做它在客户端使用JavaScript来代替:
Do it on the client-side with JavaScript instead:
var button = document.getElementById('yourButton');
button.disabled = true;
如果你使用回发到服务器所面临的问题,看看这篇文章:<一href=\"http://weblogs.asp.net/jeffwids/archive/2009/10/06/how-to-disable-an-asp-net-button-when-clicked.aspx\"相对=nofollow>如何点击时禁用ASP.NET按钮。
If you're facing issues with posting back to the server, check out this article: How to disable an ASP.NET button when clicked.
这篇关于在点击即时禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!