Page_Load called twice?

Discussion in 'ASP .Net' started by Paul, Oct 22, 2007.

  1. Paul

    Paul Guest

    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.
     
    Paul, Oct 22, 2007
    #1
    1. Advertising

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

    "Paul" wrote:

    > 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.
    >
    >
    >
     
    =?Utf-8?B?UG9rZXJKb2tlcg==?=, Oct 22, 2007
    #2
    1. Advertising

  3. Paul

    xke Guest

    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


    On Oct 22, 5:10 pm, Paul <> wrote:
    > 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.
     
    xke, Oct 23, 2007
    #3
  4. Paul

    anonymous Guest

    Set your AutoEventWireup in your ASPX to false
     
    anonymous, Oct 24, 2007
    #4
  5. Paul

    Paul Guest

    anonymous wrote:
    > 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.
     
    Paul, Oct 24, 2007
    #5
    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. Andy

    Page_Load called twice???

    Andy, Oct 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    5,023
  2. bminder
    Replies:
    1
    Views:
    2,195
    nfedin
    Feb 23, 2004
  3. z. f.
    Replies:
    0
    Views:
    579
    z. f.
    Oct 19, 2004
  4. Dot net work
    Replies:
    6
    Views:
    5,339
    Dot net work
    Nov 24, 2004
  5. Imran Aziz

    Page_load called twice on button click

    Imran Aziz, Sep 3, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    6,597
Loading...

Share This Page