Newbie -- Page_Load( ) fires twice if image is added to Login page

  • Thread starter Frank Milverckowitz
  • Start date

F

Frank Milverckowitz

Hi,

I'm using Visual Studio 2005 + ASP.NET and C#

I have a login.aspx page with AutoEventWireup set to FALSE (also added to
top level Web.Config, and set to false)

With a "template" loginCtl the Page_Load( ) event fires once.

As soon as I add an ImageCtl or just drag an image using the designer, onto
the login page and then run it, I'm seeing the Page_Init( ) and Page_Load( )
functions being fired twice.

If I remove the image, then these methods are only fired once.

Any ideas?

I am setting the event delegate like this in my login.aspx.cs file:

protected override void OnInit( EventArgs e )
{
this.Load += new EventHandler( Page_Load );
}

protected void Page_Load( .... etc.


Thanks for any tips,

Frank
 
Ad

Advertisements

K

Keith Patrick

This isn't a direct answer, but I personally avoid that this.Load += new
EventHandler(Page_Load) stuff that the wizard puts in like the plague. The
reason being is that I subclass pages a lot, and when you depend on wiring
up events, you can run into issues where a subclass won't call the base
initializer, or the listeners get added in an order that prevents proper
handling (I'd have to dig up an example, but I had issues with Page_Load
never firing at all). Since you're overriding OnInit just to wire up an
event handler, I'd just override OnLoad and see if that might prevent the
double-hit (plus, you're plugging into the vtable instead of having to deal
with event firing/delegate calling)
 

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

Top