tags:

views:

254

answers:

3

I'm using ASP.NET 2.0 under VS 2005.

Page_Load is getting called twice for my .aspx pages. AutoEventWireup is set to true, but even if I set it to false and manually add the EventHandler, it still gets fired twice.

// also set AutoEventWireup to false
public _Default() {
    this.Load += new EventHander(this.Page_Load);
}
// oops -- fired twice

In the Default.aspx page, after the user enters their username & password, I do a redirect to another page, but it seems to redirect back to the Default.aspx page.

I don't have any <img> tags without a src. The tags that have a RunAt="server" attribute are <asp:PlaceHolder>.

For everything else, I use YUI CSS and JavaScript. I don't have any <ASP:> controls.

What am I missing?

Update

I'm using the Button widget from the YUI library. If you specify "submit" in both Javascript and in the HTML code for a button, then when you submit, that JavaScript event gets generated twice.

This was a pain to figure out: I started commenting out bits and pieces of JavaScript and CSS (especially the includes), until the event fired only once.

+4  A: 

A redirect is a postback in ASP.NET. If you trigger an event(enter user name and click, 1 postback), redirect to the same page(2nd postback). Am I understanding you correctly?

rick schott
yep that's right
sri
Then it is acting exactly how it should.
rick schott
Sorry, I wasn't clear. The redirect is to a different page. But after the redirect, in comes back to the same page and doesn't go to the other page.
sri
You need to post some code, your use case isn't clear.
rick schott
A: 

Are you by any chance using this.PreviousPage in the redirected Page ?

The King
Nope. Just Response.Redirect
sri
A: 

So I'm using the YUI framework. And I'm using the Button widget. If you specify "submit" in both Javascript and in the HTML code for a button, then when you submit, that Javascript event gets generated twice. Just remove one of the submits.

This was a pain to figure out: just start commenting out bits and pieces of Javascript and CSS (especially the includes), until the event fires only once. That way you can see what is causing the Page_Load to get fired twice.

sri