G
Guest
I'm trying to better understand the use of inheritance vs. the
implementation of a handler. I wanted to ask this question to the newsgroup.
Each aspx page is a class which Inherits System.Web.UI.Page.
Then, each page has it's own implementation of Private Sub Page_Load and
Private Sub Page_Init to handle the Handles MyBase.Load and Handles
MyBase.Init events (respectively). The programmer (you or me) is supposed to
flesh out the Pgae_Load and, if you are using the Visual Studio designer,
not touch the Page_Init event handlers.
Instead of this, why don't these page classes, which are subclasses of
System.Web.UI.Page just overload the superclasses of the OnInit and OnLoad
classes? That would seem to make more sense from a class hierarchy
standpoint. Each page class, for example
'Instead of this:
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
'Do this:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'Put user code to initialize the page here
MyBase.OnLoad(e)
End Sub 'OnInit
End Class
implementation of a handler. I wanted to ask this question to the newsgroup.
Each aspx page is a class which Inherits System.Web.UI.Page.
Then, each page has it's own implementation of Private Sub Page_Load and
Private Sub Page_Init to handle the Handles MyBase.Load and Handles
MyBase.Init events (respectively). The programmer (you or me) is supposed to
flesh out the Pgae_Load and, if you are using the Visual Studio designer,
not touch the Page_Init event handlers.
Instead of this, why don't these page classes, which are subclasses of
System.Web.UI.Page just overload the superclasses of the OnInit and OnLoad
classes? That would seem to make more sense from a class hierarchy
standpoint. Each page class, for example
'Instead of this:
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
'Do this:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'Put user code to initialize the page here
MyBase.OnLoad(e)
End Sub 'OnInit
End Class