Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Load event behavior

    Hello,

    I just don't get it. I have a simple webform1.aspx page, when loaded
    for the first time, the load even fires which is fine.

    In webform1.aspx i have a button that has a onclick event, and in this
    event i do a response.redirect to webform2.aspx page. However on the
    onclick event of the button, the Load event for webform1.aspx is
    loaded again! Then the redirection is done!

    And that's not all: once we are in webform2.aspx, if i do a
    response.redirect to webform1.aspx, the load event in webform1.aspx
    fires twice!

    Could please someone explain me this weird behavior please? Thanks
    Matt Guest

  2. Similar Questions and Discussions

    1. Document Load Completion Event
      Does anyone know the last file or function that is called DW completes opening a document?
    2. Object reference error in UserControl's Load event
      I have a UserControl that I declare programmatically as follows: Dim userctrl as New rightside_portal() The codebehind file for this...
    3. Best event to load usercontrols in ASP.NET 2.0
      Hi My question is what is the best event in the page and in the user controls to dynamilly load the user controls, and why CreateChildControls is...
    4. Having a checkbox column and the grid disabled upon first load generated wierd behavior when Postback occurs.
      I have a grid with a checkbox column in it, that is disabled at Form_Load but it loaded with data anyway. Selecting a radio button enables it but...
    5. Page Load Event Fires Twice
      This is a classic asp newsgroup. While you may be lucky enough to find a dotnet-savvy person here who can answer your question, you can eliminate...
  3. #2

    Default Re: Load event behavior

    Matt

    "Matt" <metal@rocks.com> wrote in message
    news:md69hv8oiqk5f5brb8snm1des78pvr5f4v@4ax.com...
    > Hello,
    >
    > I just don't get it. I have a simple webform1.aspx page, when loaded
    > for the first time, the load even fires which is fine.
    >
    > In webform1.aspx i have a button that has a onclick event, and in this
    > event i do a response.redirect to webform2.aspx page. However on the
    > onclick event of the button, the Load event for webform1.aspx is
    > loaded again! Then the redirection is done!
    >
    > And that's not all: once we are in webform2.aspx, if i do a
    > response.redirect to webform1.aspx, the load event in webform1.aspx
    > fires twice!
    >
    > Could please someone explain me this weird behavior please? Thanks
    Use IsPostBack in the Load event to determine if it is a post back or not.
    Load will run every time the

    private void Page_Load(object sender, System.EventArgs e) {
    if (IsPostBack) {
    // This would be run if the page is posted back like in your situation
    // Do some code
    } else {
    // this would be executed the first time the page is loaded
    // do some other code
    }

    Kevin Bilbee


    Kevin Bilbee Guest

  4. #3

    Default Re: Load event behavior

    If you don't want the load event to fire why are you redirecting at all ?
    You could just go directly to webform2 via a hyperlink or some client side
    JS behind the button. That will save asp.net from having to fire up webform1
    when it isn't really needed.


    Damian




    "Matt" <metal@rocks.com> wrote in message
    news:md69hv8oiqk5f5brb8snm1des78pvr5f4v@4ax.com...
    > Hello,
    >
    > I just don't get it. I have a simple webform1.aspx page, when loaded
    > for the first time, the load even fires which is fine.
    >
    > In webform1.aspx i have a button that has a onclick event, and in this
    > event i do a response.redirect to webform2.aspx page. However on the
    > onclick event of the button, the Load event for webform1.aspx is
    > loaded again! Then the redirection is done!
    >
    > And that's not all: once we are in webform2.aspx, if i do a
    > response.redirect to webform1.aspx, the load event in webform1.aspx
    > fires twice!
    >
    > Could please someone explain me this weird behavior please? Thanks

    Damian Maclennan Guest

  5. #4

    Default Re: Load event behavior

    Hi,

    Could you send sample code ? I try to create this senario on machine
    without any luck.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139