How to disable submit behaviour of asp:ImageButton?

前端 未结 8 1805
小蘑菇
小蘑菇 2020-12-02 00:12

I have a image button in a page which can be triggered on mouse click, by default it gets triggered on enter press also which i want to disable.

I know about \"UseSu

8条回答
  •  执笔经年
    2020-12-02 00:27

    Use an asp:image instead. Then place some javascript code in the onclick "javascript:document.getElementById('imageClicked').setAttribute('value', 'true'); document.myform.submit();"

    Set a hidden field's value (using javascript) to tell the server side code that the image was clicked.

    document.getElementById('imageClicked').setAttribute('value', 'true');
    

    Then, at the end of handling the postback on the server reset the hiddenField's value:

    document.getElementById('imageClicked').setAttribute('value', 'true');
    

提交回复
热议问题