Page_Load called twice?

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I have a problem with asp.net 2.0 I've never seen before. On loading the page it
loads twice and IsPostback is false both times. This happens if I use:

Response.Redirect("somepage.aspx");

I've never had this problem on a page before.

But with Server.Transfer the problem goes away, but why?

Server.Transfer("somepage.aspx");


Here is the button:

<asp:Button ID="btnDoSomething" CssClass="somebuttonclass" runat="server"
CausesValidation="False" Text="Do it" OnClick="btnAddNewItem_Click" ></asp:Button>

There is nothing out of the ordinary on the pages.
 
Check and see what the Page_load event handles. if the project was upgraded
at some point from 1.1, you often find Mybase.load as well as me.load. If
that is the case, delete both of them, and then double click the form in
design mode to re-add the correct event ( i cant remember off the top of my
head which one is the 2.0 verison)
 
Hi Paul,

It may only be a typo on what you've posted:

<asp:Button ID="btnDoSomething" CssClass="somebuttonclass"
runat="server" CausesValidation="False" Text="Do it"
OnClick="btnAddNewItem_Click" ></asp:Button>

shouldn't be ?

<asp:Button ID="btnDoSomething" CssClass="somebuttonclass"
runat="server" CausesValidation="False" Text="Do it"
OnClick="btnDoSomething_Click" ></asp:Button>

Let me know,

xke
 
anonymous said:
Set your AutoEventWireup in your ASPX to false

I tried that, it didn't work, and some of the controls in the page didn't
postback any more. So I just went with Server.Transfer which didn't cause the
extra page load.
 
Back
Top