Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page.Load issue in ASP.NET 2.0

I am trying to aid another programmer with a page called Default.aspx with a code-behind section, and unfortunately I am at a bit of a loss.

 Partial Class _Default
 Inherits OverheadClass
 'A bunch of global variables here'

 Private Sub page_load(ByVal sender As Object, ByVal e As System.Eventarts) Handles Me.Load
 'Function goes here'

And in the OverheadClass we have

 Public Sub Sub_OverheadClass_Load(ByVal sender As Object, ByVal e as System.EventArgs) Handles MyClass.Load

The desired effect is when the OverheadClass is inherited, we want its load to run before the load event on the page runs. There is probably a very simple answer to this that I am missing.

Edit: I forgot to note that we write in VB, and not C# as many of you are used to for ASP.

like image 559
Maximillian Avatar asked Jan 21 '26 02:01

Maximillian


2 Answers

You should be able to override the OnLoad and call the base class's OnLoad first, then your class, for example:

C# Version

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);

    // Do some stuff here
}

VB Version

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

    MyBase.OnLoad(e)

    ' Do some stuff here

End Sub
like image 183
mattruma Avatar answered Jan 22 '26 16:01

mattruma


In VB it would be:

Private Sub page_load(ByVal sender As Object, ByVal e As System.Eventarts) Handles Me.Load
  Mybase.Sub_OverheadClass_Load(e)
End Sub
like image 27
Brian Schmitt Avatar answered Jan 22 '26 17:01

Brian Schmitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!