button firing click event twice

后端 未结 14 2076
忘了有多久
忘了有多久 2021-02-07 21:28

It seems that sometimes (but not always) my button click event is being fired twice. The fact that it seems to happen sometimes but not always is really puzzling me. Here is m

14条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 22:04

    I just came across this same problem and wanted to point out that removing the "Handles btnSave.Click" from your event will prevent it from being called twice. For Example, use this in the code behind:

    Protected Sub btnSave_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
        'Do Something
    End Sub
    

    Instead of this:

    Protected Sub _btnSave_OnClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        'Do Something
    End Sub
    

提交回复
热议问题