I am adding event handlers to a button like this:
btn.Click += new EventHandler(btn_Click);
However the btn_Click
function is not being called (never hits the breakpoint in it) and the button just reloads the page. In my past experience, asp buttons usually perform the click code before reloading the page, so how do I get that to happen when the event is dynamically added?
I also set CausesValidation = false
, although there's no validation on the page so I don't think that would have influence anyway.