AutoEventWireup, inherited pages - page base class

P

Phil Johnson

Hi, I am working on an application with around 800 pages.

It was an asp.net 1.1 application with all the pages having AutoEventWireup
set to False and the events hooked up in the code behind.

The pages all inherit from a base class we called PageBase.cs which also has
a load and unload event handler that gets wired up inside it which runs on
every page's load and unload as well.

We upgraded the application to a 3.5 application and that seemed to set the
AutoEventWireup to true on most pages and pull out the event wireups from the
code behind. Now about 600 pages have the AutoEventWireup set to True and
200 have it set to false.

The problem I have is that on the pages where it is set to true, the load
and unload events in the page base fire twice.

Is there any way we can get around this issue?

One thing I will try is changing the name of the event handlers in the
PageBase.cs class so the autoeventwireup doesn't affect them and still hook
them up manually.

Any other ideas that might work?

Or any getarounds?

Ideally, does anybody know of an automated way to replace the
autoeventwireups with explicit event hookups? Resharper or Refactor or
another tool?

Thanks
 
G

Gregory A. Beamer

The problem I have is that on the pages where it is set to true, the
load and unload events in the page base fire twice.

Is there any way we can get around this issue?

Most likely, the upgrade created a wire in a designer file. This is
extremely likely if you upgraded to a web application template, but I
imagine it can happen in a website template, as well.
One thing I will try is changing the name of the event handlers in the
PageBase.cs class so the autoeventwireup doesn't affect them and still
hook them up manually.

Any other ideas that might work?

Create a new project, create new pages, and drag and drop the code and
tags over, sans the hard coded event handlers and @ page directives.

Allow ASP.NET to wire them for you as it would with any new page. You
are going to end up touching every page anyway and this will likely
clean up the code in the process.

Currently, you are going to spin a lot of time on something that is a
bit of a kludge. Why not spend the time cleaning things up.

Do this on a page or two first and make sure the code does not have
other issues.
Or any getarounds?

Ideally, does anybody know of an automated way to replace the
autoeventwireups with explicit event hookups? Resharper or Refactor
or another tool?


None of the tools I know has this refactor in it.
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top