按钮点击后禁用功能 [英] Button disable function after clicking on it
问题描述
我有保存约150页按钮。以往用户点击Save按钮时,我应该点击后禁用按钮。使用户不保留再次点击保存按钮。
i have save button in around 150 pages. when ever the user clicks on save button i should disable the button after the click. so that user does not keep clicking on save button again.
protected void Button1_Click(object sender, EventArgs e)
{
// right now once the user clicks the save button
Button1.Enabled = "false"
}
现在我做这样的。有没有更好的解决办法u能提供我在这里提高codeING将是巨大的。
right now i am doing like this. is there any better solution u can provide me to improve codeing here would be great.
感谢您
推荐答案
我想做到这一点是使用JavaScript的最佳选择。如果您在使用jQuery(我可以甚至开始建议足够的),那么你可以把中的JavaScript功能母版。你只需要找到一种方法来为你保存按钮的选择。像这样的:
I think the best option to accomplish this is using javascript. If you are using jQuery (which I can even start to recommend enough) then you can put the javascript in your masterpage. You just need to find a way to create a selector for your save buttons. Like this:
$(document).ready(function(){
$('.saveButton').bind("click", function(e) {
$(this).attr("disabled", "true");
return true; //causes the client side script to run.
});
});
在这个例子中,我认为所有的保存按钮,将有css类.saveButton,但你可以找到你自己的方式来选择按钮。
In this example, I assumed that all the save buttons would have the css class ".saveButton", but you can find your own way to select the button.
干杯!
这篇关于按钮点击后禁用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!