admin管理员组文章数量:1323723
I have an imagebutton in my aspx page like:
<asp:ImageButton ID="btnProcessPayment" ImageUrl="~/Images/process-payment.png" OnClientClick="return disableButton(this);"
runat="server" OnClick="btnProcessPayment_Click" />
This is my javascript function:
function disableButton(button) {
button.disabled = true;
return true;
}
As you can see in my javascript event handler I have disabled the button to prevent the user from click the button twice. However, even my server side event handler doesn't get fired due to this. What am I doing wrong?
Note: If I ment out this line button.disabled = true;
all works out pretty well.
I have an imagebutton in my aspx page like:
<asp:ImageButton ID="btnProcessPayment" ImageUrl="~/Images/process-payment.png" OnClientClick="return disableButton(this);"
runat="server" OnClick="btnProcessPayment_Click" />
This is my javascript function:
function disableButton(button) {
button.disabled = true;
return true;
}
As you can see in my javascript event handler I have disabled the button to prevent the user from click the button twice. However, even my server side event handler doesn't get fired due to this. What am I doing wrong?
Note: If I ment out this line button.disabled = true;
all works out pretty well.
- I just noticed the same issue. At least I'm not the only one. – Sam Rueby Commented Mar 8, 2012 at 3:01
3 Answers
Reset to default 5Disabling the button disables the form submit as well. You need to do the submit yourself:
function disableButton(button) {
button.disabled = true;
__doPostBack(<%= btnProcessPayment.ClientID %>,''); // need to manually submit
return true;
}
Updated as per Waqas suggestion!
You need to fire out serverside event of the button some thing like this
onclick="this.disabled=true;__doPostBack('buttonclientid','');"
or
function disableButton(button) {
button.disabled = true;
__doPostBack('buttonclientid','');
return true;
}
Use this and it worked for me
__doPostBack('<%= btnSubmit.ClientID %>', '');
where btnSubmit
is the ID of my button and I wanted to trigger the server side click event for the button. It works.
本文标签: cDisabling a button doesn39t fire click event on server sideStack Overflow
版权声明:本文标题:c# - Disabling a button doesn't fire click event on server side - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742123955a2421851.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论