locked
Button_Click event fires twice RRS feed

  • Question

  •  Hi,

    I've created sample silverlight application. It has  two buttons and handlers are attached to the Click event of them.

    I observed that the Click event of the button is executed twice! What could be the reason?

    Thursday, August 13, 2009 8:19 AM

Answers

  •  I figured out the problem. It was because i had registered the current ' button_click' event handler on the Page_Load event which was unnecessary. It was executing the "Button_Click" event handler twice.

    Thursday, August 13, 2009 8:29 AM

All replies

  •  I figured out the problem. It was because i had registered the current ' button_click' event handler on the Page_Load event which was unnecessary. It was executing the "Button_Click" event handler twice.

    Thursday, August 13, 2009 8:29 AM
  • Have you wired the event up for the button click twice?

    A common mistake is to set the event up in xaml then also wire it up in the code behind.

    Thursday, August 13, 2009 8:29 AM