Jquery asp.net Button Click Event via ajax

后端 未结 5 803
情话喂你
情话喂你 2020-12-12 17:13

I was wondering if anyone can point me in the right direction. I have an asp.net button with a click event (that runs some server side code). What i\'d like to do is call t

5条回答
  •  孤街浪徒
    2020-12-12 18:14

    I like Gromer's answer, but it leaves me with a question: What if I have multiple 'btnAwesome's in different controls?

    To cater for that possibility, I would do the following:

    $(document).ready(function() {
      $('#<%=myButton.ClientID %>').click(function() {
        // Do client side button click stuff here.
      });
    });
    

    It's not a regex match, but in my opinion, a regex match isn't what's needed here. If you're referencing a particular button, you want a precise text match such as this.

    If, however, you want to do the same action for every btnAwesome, then go with Gromer's answer.

提交回复
热议问题