Losing Event Wireup Code

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I am so happy to have mastered the technique for "Press Tab to
insert".
I type " += " and up steps Visual Studio to write my event handler for
me.
This is more fun than Intellisense.

But I keep losing my Event Wireup, or Delegate Assignment, code from
the "InitializeComponent" section of the page.

For example,
I just had to re-insert the following into InitializeComponent :

this.bttnGo.Click +=new EventHandler(bttnGo_Click);

Anybody else experience this in C# ASP .NET?

Brian
 
I've seen this happen frequently when copying and pasting controls.

You can also go to the events view of the property window and reselect the
appropriate handler.

HTH;
Eric Cadwell
http://www.origincontrols.com
 
Hi Brian,

There was another post today regarding this, it seems that
InitializeComponent method is not a safe place to put your code, I would
suggest you to put the code in other place like in the Load handler, in fact
I just took a look at one of my pages and this is the comment above that
method:

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()

Cheers,
 
Thanks everybody!

Your tips are both helpful.
I had never used the "Events" window before.

I thought the comment about staying out of the "init" code was only
applicable to people using "AutoEventWireUp".

I will use both techniques you offered where needed.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top