autoeventwireup Changed to True in C# Conversion to WAP

Last post 10-31-2008 3:09 AM by Abinash Patra. 4 replies.

Sort Posts:

  • autoeventwireup Changed to True in C# Conversion to WAP

    07-12-2006, 4:15 PM
    • Member
      5 point Member
    • amy.baker
    • Member since 07-12-2006, 7:47 PM
    • Posts 1

    Background:

    We are converting a project from asp.net 1.1 to 2.0 and also moving from VS2003 to VS2005. We are trying to use VS2005 Web Application Projects.

    Issue:

    When we selected to Convert to a Web Application Project, the wizard did the following that we did not anticipate:

    1. Changed the autoeventwireup attribute in our aspx, ascx pages to "True". We had it set to false previously  for better performance.
    2. Removed all event wiring from the code behind pages. The OnInit method was removed and the wireup from the InitializeComponent was removed, e.g.:

    //Code behind before WAP Conversion:
    override protected void OnInit(EventArgs e)
    {
      InitializeComponent();
      base.OnInit(e);
    }

    private void InitializeComponent()
    {
      this.Load += new System.EventHandler(this.Page_Load);
    }

    //Code behind after WAP Conversion:
    private void InitializeComponent()
    {
    }

    Questions:

    1. Why is Microsoft pushing autoeventwireup=true? Is it the preferred way to go forward? We have had it set to false in the past for better performance but we don't want to set it to false if Microsoft will be assuming it is true and building on top of that going forward.
    2. Why is it now so hard to change the default to autoeventwireup=false? We have to:
      1. change the templates to include the OnInit and wireup of Page_Load
      2. add wiring code every time we hook up an event
      3. manually add all of the events back into the code behind after the WAP conversion
    3. What is the performance overhead of autoeventwireup=true? It creates delegates at runtime to handle the wiring, correct?
    4. Is there a configuration setting we can set so the autoeventwireup and wiring will not be touched during the WAP conversion?  In order to leave autoeventwireup=false, we have spent many hours after the conversion to try to set it back to false and will have to spend many more hours. Here is what we have had to do manually:
      1. Find and change all of the templates that specify autoeventwireup=true.
      2. Set the autoeventwireup back to false in the aspx, ascx.
      3. Re-add the OnInit() method and all event wiring by looking at code history in our source control and manually adding the event wiring back in. This is obviously a very risky approach. We are in the middle of it and decided to stop until we could get some help.
     
     
     
  • Re: autoeventwireup Changed to True in C# Conversion to WAP

    08-31-2006, 12:47 PM
    • Member
      14 point Member
    • Ian1971
    • Member since 04-28-2005, 12:34 PM
    • London
    • Posts 23

    Hi Amy,

    I am running into the same problem. I can't understand why they did this. Performance is worse and I now have a laborious task fixing all the double event firing I now have.

    Did you get anywhere with your point 4 so you could convert but leave the autoeventwireup intact?

    Regards

    Ian
     

  • Re: autoeventwireup Changed to True in C# Conversion to WAP

    08-31-2006, 6:46 PM
    • Contributor
      3,039 point Contributor
    • Wee Bubba
    • Member since 11-24-2003, 11:23 AM
    • Australia
    • Posts 644

    although this does not help you with your current problem, it may come in useful for future projects.

    i suggest wiring your event handlers up in a separate method within each page. then you reference this method from the OnInit event. VS 2003 had a habit of removing any custom handlers whenever i went into design mode, so this is what i did as a fix, and this has also saved me running into the problems you have stated when i ported over to .NET 2.0.

     


  • Re: autoeventwireup Changed to True in C# Conversion to WAP

    12-16-2007, 8:39 PM
    • Member
      259 point Member
    • MNF
    • Member since 07-25-2005, 12:15 AM
    • Posts 72
    I have similar problem after I've used "Convert to Web Application" menu for my ASCX file that has AutoEventWireup="false".

    Convertion left AutoEventWireup="false" in control declaration, but removed all +EventHandler  lines from InitializeComponent.

    I had to manually restore them.

    I am using VS2005 SP1.

  • Re: autoeventwireup Changed to True in C# Conversion to WAP

    10-31-2008, 3:09 AM
    • Member
      2 point Member
    • Abinash Patra
    • Member since 10-31-2008, 2:46 AM
    • Posts 1

    Hello,

    I have made the AutoEvenrWireup to "False". But I didn't put any evenr wire up code in the

    InitializeComponent() method. But still all the events are workig fine. How is this possible? I don't see any reference for event handlers.

Page 1 of 1 (5 items)