Page_Load called twice?

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

Guest

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)
 
X

xke

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
 
P

Paul

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.
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top