difference between Page_Load() and OnLoad() ?

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

  1. #1

    Default difference between Page_Load() and OnLoad() ?

    hi,

    what is the difference between the Page_Load() and OnLoad() event handlers.
    do they originate from a different point ?



    Christian Guest

  2. Similar Questions and Discussions

    1. Page_Load issue
      Hi, I am relatively knew to the ASP .Net world, so I may be going about this all wrong, but I need to figure this out anyway. I am using a IE...
    2. Why bad with Page_Load
      I have an XML Web Servic (.asmx) to generate an Excel file, and it works as expected. However, here is the bad thing, - if this web service is...
    3. page_load
      I've got an aspx and I need that his page_load event be fired every time I enter the page. Actually I put a break point in the first line in the...
    4. progress bar and page_load
      Hi Basically I call a page that does a very long op But I need to display a progress bar no frames There is an old trick in html and asp ...
    5. Page_Init() and Page_Load()
      Hi, what is the purpose of having a Page_Init() AND a Page_Load() event handler 'cause both will always be executed on loading a page ? What...
  3. #2

    Default difference between Page_Load() and OnLoad() ?

    OnLoad is a protected method that is raised by the Load
    event. I believe this method then calls Page_Load().

    Tu-Thach
    >-----Original Message-----
    >hi,
    >
    >what is the difference between the Page_Load() and OnLoad
    () event handlers.
    >do they originate from a different point ?
    >
    >
    >
    >.
    >
    Tu-Thach Guest

  4. #3

    Default Re: difference between Page_Load() and OnLoad() ?

    the strange thing though is that when I implement both functions only
    OnLoad()
    is invoked and Page_Load() never is ???

    same as with OnInit() and Page_Init()

    christian

    "Nikolaus Hruska" <nhruska@nist.gov> wrote in message
    news:O88LgU9SDHA.2004@TK2MSFTNGP11.phx.gbl...
    > Onload raises the Load event.
    >
    > if you want to selectively fire the Load event, override OnLoad, and check
    > the necessary conditions.
    >
    > ex:
    >
    > Protected Sub OnLoad(sender as object, e as eventargs)
    >
    > 'only fire load event if condition is met
    > If myCondition = True Then
    > MyBase.OnLoad()
    > End If
    > End Sub
    >
    > --
    > Nikolaus R. Hruska
    > AASHTO Materials Reference Laboratory
    > National Institute of Standards and Technology
    > [url]http://amrl.net[/url]
    > [email]nhruska@amrl.net[/email]
    > "Rob Epstein" <repstein@auctionworks.com> wrote in message
    > news:eYl9sQ9SDHA.2148@TK2MSFTNGP10.phx.gbl...
    > > Christian,
    > >
    > > Page_Load() is a private function created by VS.NET that it then ties to
    > > the OnLoad event of the Page class in the InitializeComponents function.
    > > As I understand it, there is no need for this step since OnLoad is a
    > > protected function in the Page class that can be overriden. Just make
    > > sure you call the base OnLoad function in your overloaded version.
    > >
    > > Rob Epstein
    > > Sr Developer, AuctionWorks Inc.
    > >
    > > Christian wrote:
    > > > hi,
    > > >
    > > > what is the difference between the Page_Load() and OnLoad() event
    > handlers.
    > > > do they originate from a different point ?
    > > >
    > > >
    > > >
    > >
    >
    >

    Christian Guest

  5. #4

    Default Re: difference between Page_Load() and OnLoad() ?


    "Christian" <christian.cambier@pandora.be> wrote in message
    news:G4kRa.14404$F92.1251@afrodite.telenet-ops.be...
    > the strange thing though is that when I implement both functions only
    > OnLoad()
    > is invoked and Page_Load() never is ???
    The Page_Load() event handler needs to be added to the Load event of the
    page class. If you're using VS.NET the IDE normally adds code that does
    this for you at page init time in an override of the OnInit() method (it's
    in a region of code marked with a "#region Web Form Designer generated code"
    directive).

    Another possible problem is that your override of the OnLoad() method is not
    calling base.OnLoad() which is where the event handers registered in the
    Load event will be called.
    >
    > same as with OnInit() and Page_Init()
    >
    > christian
    >
    > "Nikolaus Hruska" <nhruska@nist.gov> wrote in message
    > news:O88LgU9SDHA.2004@TK2MSFTNGP11.phx.gbl...
    > > Onload raises the Load event.
    > >
    > > if you want to selectively fire the Load event, override OnLoad, and
    check
    > > the necessary conditions.
    > >
    > > ex:
    > >
    > > Protected Sub OnLoad(sender as object, e as eventargs)
    > >
    > > 'only fire load event if condition is met
    > > If myCondition = True Then
    > > MyBase.OnLoad()
    > > End If
    > > End Sub
    > >
    > > --
    > > Nikolaus R. Hruska
    > > AASHTO Materials Reference Laboratory
    > > National Institute of Standards and Technology
    > > [url]http://amrl.net[/url]
    > > [email]nhruska@amrl.net[/email]
    > > "Rob Epstein" <repstein@auctionworks.com> wrote in message
    > > news:eYl9sQ9SDHA.2148@TK2MSFTNGP10.phx.gbl...
    > > > Christian,
    > > >
    > > > Page_Load() is a private function created by VS.NET that it then ties
    to
    > > > the OnLoad event of the Page class in the InitializeComponents
    function.
    > > > As I understand it, there is no need for this step since OnLoad is a
    > > > protected function in the Page class that can be overriden. Just make
    > > > sure you call the base OnLoad function in your overloaded version.
    > > >
    > > > Rob Epstein
    > > > Sr Developer, AuctionWorks Inc.
    > > >
    > > > Christian wrote:
    > > > > hi,
    > > > >
    > > > > what is the difference between the Page_Load() and OnLoad() event
    > > handlers.
    > > > > do they originate from a different point ?
    > > > >
    > > > >
    > > > >
    > > >
    > >
    > >
    >
    >
    --
    MikeB


    MikeB 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