You'll want to do a couple things...
First, remove the "Handles MyBase.Load" from your Page_Load method in your
classes (like ABCCustomerSelect ). The Handles statement automatically
registers that method for an event, behind the scenes. Also, make
Page_Load a public method. We'll refer to it later from your child classes.
Next, add a "Sub New" to these base classes, as this will be your class
constructor. In this method, you'll want to register your Page_Load event
by hand. That command is:
AddHandler Load, Page_Load
So, now everything should function like it currently does -- the next step
is to remove the event handler as needed. In your child class
(ABCPocketSelect) you should put the following lines in its Sub New....
AddHandler Load, Me.Page_Load ' register its own page_load
RemoveHandler Load, MyBase.Page_Load ' remove its parent's page_load
So, check out AddHandler and RemoveHandler in help, it will explain more
about what's going on there.
-Charlie
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).
--------------------
>From: "WFB" <>
>Subject: Inherited Page Always Calls Base Page Load Event
>Date: Tue, 30 Dec 2003 09:50:02 -0500
>Lines: 37
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: bkftpout.com 12.4.211.11
>Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!cpmsftng xa09.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP10.phx.gbl
>Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:198847
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>Hi,
>
>I have a base class from which all of my pages derive (ABCBasePage). For
>example, ABCCustomerSelect Inherits ABCPasePage. I would now like to have
>ABCPocketSelect which should inherit from ABCCustomerSelect. My problem is
>that when ABCPocketSelect is loaded the Page_Load event in ABCBasePage is
>called, followed by the load event for ABCCustomerSelect - and I would like
>to skip the ABCCustomerSelect load event..
>
>My basic code is as follows:
>
>Public Class ABCBasePage : Inherits Page
> Private Sub Page_Load(Sender as Object, e as System.EventArgs) Handles
>MyBase.Load
> 'Do code here that should happen on ALL pages
> End Sub
>End Class
>
>Public Class ABCCustomerSelect : Inherits ABCBasePage
> Private Sub Page_Load(Sender as Object, e as System.EventArgs) Handles
>MyBase.Load
> 'Do code here that should happen ABCCustomerSelect only
> End Sub
>End Class
>
>Public Class ABCPocketSelect : Inherits ABCBasePage
> Private Sub Page_Load(Sender as Object, e as System.EventArgs) Handles
>MyBase.Load
> 'Do code here that should happen ABCPocketSelect only
> End Sub
>End Class
>
>Thanks for any help.
>
>Joe
>
>
>
|