views:

867

answers:

6

Hello,

When clicking button in debug mode, the page reloads but the break points inside of the click event are never reached. However, breakpoints in the page_load work just fine.

Basically, it's as if code inside of the button's click event is not being executed.

I checked the site into source control and another developer tried it on his computer. The click events worked just fine there, catching the break points inside.

I tried another site on my computer and it has the same issue. So it's something specific to my computer, and not specific to any site.

Is there some setting I may have mistakenly changed that could cause click events to stop working while debugging?

Any help would be appreciated.

Edited: This issue is happening on all sites I run in my debugger, and the buttons are not created dynamically.

Edited: There are no indication of problems when adding the break points. I don't think it's a breakpoint issue, I believe it's an issue with click events not firing. I put identical code on another developers machine and the click event's worked fine while debugging on that machine.

A: 

How is the button created? If it's added to the page dynamically, remember that this must be done before the load event, or the events won't be wired up. That is the most common reason I've heard for this kind of thing.

Joel Coehoorn
Joel, why before? It works just as fine if created on Page_Load event.
Ruslan
Because of the page life cycle: state, including wired events, are restored just before the page load. If you wait until the load event to recreate the control on postbacks it won't exist when asp.net tries to wire up the event handler, and the event will never fire.
Joel Coehoorn
A: 

Does it say that "symbols will not be loaded" OR "source file is different" when you put the breakpoint inside the button_click event?

If so, you have modified the code files & built the binary (which is different from what site is using).

shahkalpesh
A: 

In my Page_Load event I would check the IsPostBack property to make sure that it is actually a post and not get. I would verify that the Controls collection is populated and all control IDs match those in the Request.Forms.Keys.

The reason for this suggestion is that if you have any add-on in the browser or fancy proxy that messes up with submitted forms and input names are modified, events won't fire for those controls.

Ruslan
+1  A: 

If its something specific to your machine, and after all things fail, I would do a repair on Visual Studio. I've had to do that a couple times when things get weird and it usually works. But remember to exhaust all other avenues first.

irperez
A: 

I'll take a stab as I remember something similar:

I had upgraded an app from vs2005 to vs2008 and my button code click worked in 2005, but in 2008 I needed to add a "Handles" qualifier at the end of the declaration like this:

Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click

for whatever reason the 2005 code didn't need it, but the 2008 required it, and I vaguely remember having the very same symptoms you are describing.

EJB
A: 

So it seems all the click events I was testing were image buttons, and I didn't have the images on my local machine. For some reason, when the image was missing, the click event wouldn't fire.

Americus