AutoEventWireup, inherited pages - page base class

Discussion in 'ASP .Net' started by Phil Johnson, Jul 29, 2009.

  1. Phil Johnson

    Phil Johnson Guest

    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

    --
    Regards,

    Phillip Johnson
     
    Phil Johnson, Jul 29, 2009
    #1
    1. Advertising

  2. =?Utf-8?B?UGhpbCBKb2huc29u?= <>
    wrote in news::

    >
    > 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.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Jul 29, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WFB
    Replies:
    1
    Views:
    2,670
    Charlie Nilsson [MSFT]
    Dec 30, 2003
  2. Softari
    Replies:
    1
    Views:
    443
    John Harrison
    Jul 14, 2004
  3. Alicia
    Replies:
    3
    Views:
    987
    jjr2004a
    Nov 24, 2004
  4. Josh Mcfarlane
    Replies:
    2
    Views:
    350
    Josh Mcfarlane
    Aug 18, 2005
  5. 7stud --
    Replies:
    11
    Views:
    467
    7stud --
    Nov 9, 2007
Loading...

Share This Page