difference between Page_Load() and OnLoad() ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian

    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 ?



  • Tu-Thach

    #2
    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
    [color=blue]
    >-----Original Message-----
    >hi,
    >
    >what is the difference between the Page_Load() and OnLoad[/color]
    () event handlers.[color=blue]
    >do they originate from a different point ?
    >
    >
    >
    >.
    >[/color]

    Comment

    • Christian

      #3
      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.g ov> wrote in message
      news:O88LgU9SDH A.2004@TK2MSFTN GP11.phx.gbl...[color=blue]
      > 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
      > http://amrl.net
      > nhruska@amrl.ne t
      > "Rob Epstein" <repstein@aucti onworks.com> wrote in message
      > news:eYl9sQ9SDH A.2148@TK2MSFTN GP10.phx.gbl...[color=green]
      > > 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 InitializeCompo nents 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:[color=darkred]
      > > > hi,
      > > >
      > > > what is the difference between the Page_Load() and OnLoad() event[/color][/color]
      > handlers.[color=green][color=darkred]
      > > > do they originate from a different point ?
      > > >
      > > >
      > > >[/color]
      > >[/color]
      >
      >[/color]


      Comment

      • MikeB

        #4
        Re: difference between Page_Load() and OnLoad() ?


        "Christian" <christian.camb ier@pandora.be> wrote in message
        news:G4kRa.1440 4$F92.1251@afro dite.telenet-ops.be...[color=blue]
        > the strange thing though is that when I implement both functions only
        > OnLoad()
        > is invoked and Page_Load() never is ???[/color]

        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.
        [color=blue]
        >
        > same as with OnInit() and Page_Init()
        >
        > christian
        >
        > "Nikolaus Hruska" <nhruska@nist.g ov> wrote in message
        > news:O88LgU9SDH A.2004@TK2MSFTN GP11.phx.gbl...[color=green]
        > > Onload raises the Load event.
        > >
        > > if you want to selectively fire the Load event, override OnLoad, and[/color][/color]
        check[color=blue][color=green]
        > > 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
        > > http://amrl.net
        > > nhruska@amrl.ne t
        > > "Rob Epstein" <repstein@aucti onworks.com> wrote in message
        > > news:eYl9sQ9SDH A.2148@TK2MSFTN GP10.phx.gbl...[color=darkred]
        > > > Christian,
        > > >
        > > > Page_Load() is a private function created by VS.NET that it then ties[/color][/color][/color]
        to[color=blue][color=green][color=darkred]
        > > > the OnLoad event of the Page class in the InitializeCompo nents[/color][/color][/color]
        function.[color=blue][color=green][color=darkred]
        > > > 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[/color]
        > > handlers.[color=darkred]
        > > > > do they originate from a different point ?
        > > > >
        > > > >
        > > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]

        --
        MikeB


        Comment

        Working...