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
 
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
 
Back
Top