本文介绍了单击时禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带按钮的ASP.Net页面. 我需要在单击按钮时禁用该按钮,处理一些代码,并且在处理代码时应重新启用该按钮. 我写了下面的代码.
I have an ASP.Net page with a button. I need to disable the button when it is clicked, process some code and when code is processed the button should be enabled back. I wrote below code.
Button.enabled = false /* code */ Button.enabled = true但是,它不会更改按钮的状态. 我也尝试过使用JavaScript,它禁用了按钮,但不处理代码并重新启用按钮.
but, it does not change the status of the button. I also tried with JavaScript, it disables the button but doesnt process the code and reenable the button.
script.RegisterClientScriptBlock(Me.GetType(), "ButtonStatus", "document.getElementById(''ButtonName'').enables = false;") /* code */ script.RegisterClientScriptBlock(Me.GetType(), "ButtonStatus", "document.getElementById(''ButtonName'').enables = true;")关于这个人的任何建议...
Any suggestion on this guys...
推荐答案谢谢您的提问. Thank you for your question. Button1.Enabled = false; foreach (GridViewRow row1 in GridView1.Rows) { CheckBox chk = (CheckBox)row1.FindControl("chkId"); if (chk.Checked) { String strTem = chk.ID; } } Button1.Enabled = true;
我已经使用了上面的代码,但没有发现此问题作为您的问题. 谢谢
I have used above code but did not find this problem as your question. Thanks
看看这个 在Asp中禁用多个按钮单击 [ ^ ] Have a look at this one Disable Multiple Button Click in Asp[^]
Hello Sifar! 我认为/* Code */部分在服务器端执行. 如果为真,则因为启用= true ,您将看不到按钮的任何更改. 是在服务器端设置的,并且在浏览器中显示页面时,该按钮已启用. 干杯 曼弗雷德(Manfred) Hello Sifar! I take it that /* Code */ part is executed at the server side. If this is true you wont see any changes on the button since enables = true is set on the server side and when the page is displayed in the browser the button is enabled. Cheers Manfred
更多推荐
单击时禁用按钮
发布评论