Button does not respond to click event

  • Thread starter Thread starter Jeremy Ames
  • Start date Start date
J

Jeremy Ames

Repost:

Yes. I have other controls that are working correctly.
Check if ur button is in a <FORM runat='server'></FORM> or not.
I am using C# to create a web form. I have got a button that I am trying
to debug but the program doesn't ever stop at the event procedure for the
button. Here is all of the pertinent information:

aspx file:

<asp:button id="btnEditEquipment" runat="server"
CausesValidation="False" Text="Edit Equip"></asp:Button>


aspx.cs file

protected System.Web.UI.WebControls.Button btnEditEquipment;



private void InitializeComponent()

{

this.btnEditEquipment.Click += new
System.EventHandler(this.btnEditEquipment_Click);

this.Load += new System.EventHandler(this.Page_Load);

}



private void btnEditEquipment_Click(object sender, System.EventArgs e)

{

// some code goes here

}
 
I'd try:
1. Cut the click event handler to memory.
2. Rebuild the solution.
3. Paste the handler back in and test it.

I've had this happen to a number of my handlers, using VB, and not just
button events! Disturbing that all of a sudden a damned handler just
stops getting called. I went through hell with my DataGrid app with
this until I figured out what to do to fix it.

VB is different because after you delete the handler you can reselect it
from the correct DDL and the code generator will automatically recreate
the handler. Then all you have to do is paste in your code, and it
works again. In C# I guess your IDE won't do that, so you'll have to
retype it or paste the entire handler.

~Paul
 
Back
Top