Home All Groups Group Topic Archive Search About

How to obtain a reference to derived class from base?

Author
22 Oct 2007 1:39 PM
Sid DeLuca
I'm trying to centralize some initialization routines in my web application
by placing logic into a 'base form' that all web pages inherit from.

In the class for the base form, I would like to be able to reference in some
event (Pre_load, perhaps), the inheriting class without having to explicitly
pass this up as a property set.  Is there an easy way to do this?

More specifically, I'm using log4net and I want to have separate loggers for
each page where the %logger property shows as 'webForm1.aspx' instead of
'basePage.aspx' for each log entry.

Author
22 Oct 2007 5:51 PM
Mattias Sjögren
>More specifically, I'm using log4net and I want to have separate loggers for
>each page where the %logger property shows as 'webForm1.aspx' instead of
>'basePage.aspx' for each log entry.

this.GetType() will return type info for the actual type of the
current page object.

Request.FilePath returns the file path of the page being requested if
that's what you're looking for.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
22 Oct 2007 8:24 PM
Sid DeLuca
Perfect!

(Me.GetType for the vb folks out there)
Thanks, Mattias.

Show quote
"Mattias Sjögren" wrote:

>
> >More specifically, I'm using log4net and I want to have separate loggers for
> >each page where the %logger property shows as 'webForm1.aspx' instead of
> >'basePage.aspx' for each log entry.
>
> this.GetType() will return type info for the actual type of the
> current page object.
>
> Request.FilePath returns the file path of the page being requested if
> that's what you're looking for.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

AddThis Social Bookmark Button