如题。为了避免重复提交,按钮点击后客户端设为不可用,等完成后操作后在服务器端设enabled=true.
在IE9中测试没有问题,但IE8中,点击后,按钮确实是不可用了,按钮服务器端的代码也不执行了。何解?
<asp:Button ID="btn" ClientIDMode ="Static" runat ="server" Text ="测试点击后不可用" ValidationGroup ="test" OnClientClick="this.disabled='true'" OnClick="TestThis" />
Protected Sub TestThis (sender as object, e as eventargs)
数据CRUD操作....
End Sub
------解决方案--------------------------------------------------------
http://ludapeng615.blog.163.com/blog/static/3788944420071012317772/
http://www.xue5.com/itedu/200802/108571
------解决方案--------------------------------------------------------
<script language="javascript">
function abc()
{
var mybutton=document.getElementById("Submit1");
mybutton.disabled=true; //变灰
__doPostBack("Submit1",""); //执行服务器端Submit1的click事件
}
</script>
<form id="Form1" method="post" runat="server">
...
<INPUT id="Submit1" type="submit" value="开始上传" name="Submit1" runat="server">
....
</form>
------解决方案--------------------------------------------------------
http://www.cnblogs.com/blue.net/archive/2009/11/02/1594331
$("input[type='submit']").each(function ()
{
$(this).bind("click", function ()
{
$(this).attr("disabled", true);
$(this).parents().filter("form").trigger("submit");
});
});