Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Autotmate Page_load events

Reply
Thread Tools

Autotmate Page_load events

 
 
=?Utf-8?B?QWxleA==?=
Guest
Posts: n/a
 
      04-18-2005
We have a web site which we need to implement auditing. I've implemented a
base form which all code behind files inherit from, and I can add the logic
to it, but that would mean that all existing pages would need to be changed,
and any future pages would need to also implement the call code.

Is there a way to automatically call some code when a page_load has been
invoked without adding code into the Page_Load? Global.asa would be nice, but
I didn't find it usefull at a page level.
 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      04-18-2005
Alex:

Your base form could also hook up to the Page_Load event, and both the
derived form and base form could have an event handler.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 18 Apr 2005 10:25:02 -0700, "Alex"
<(E-Mail Removed)> wrote:

>We have a web site which we need to implement auditing. I've implemented a
>base form which all code behind files inherit from, and I can add the logic
>to it, but that would mean that all existing pages would need to be changed,
>and any future pages would need to also implement the call code.
>
>Is there a way to automatically call some code when a page_load has been
>invoked without adding code into the Page_Load? Global.asa would be nice, but
>I didn't find it usefull at a page level.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleA==?=
Guest
Posts: n/a
 
      04-19-2005
Can you provide with a little more detail on how I can achieve it. Maybe some
additional keywords I can search on?I don't understand how I can achieve this.

"Scott Allen" wrote:

> Alex:
>
> Your base form could also hook up to the Page_Load event, and both the
> derived form and base form could have an event handler.
>
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Mon, 18 Apr 2005 10:25:02 -0700, "Alex"
> <(E-Mail Removed)> wrote:
>
> >We have a web site which we need to implement auditing. I've implemented a
> >base form which all code behind files inherit from, and I can add the logic
> >to it, but that would mean that all existing pages would need to be changed,
> >and any future pages would need to also implement the call code.
> >
> >Is there a way to automatically call some code when a page_load has been
> >invoked without adding code into the Page_Load? Global.asa would be nice, but
> >I didn't find it usefull at a page level.

>
>

 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      04-19-2005
Hi Alex:

I was thinking of pointing you to these articles:

http://aspnet.4guysfromrolla.com/articles/041305-1.aspx
http://msdn.microsoft.com/library/de...rockASPNET.asp

but it sounds as if you already have a base class that all your
webforms derive from. In that base class you can hook the Load event
just like the derived webform does that VS.NET gives you (in C#, you
would += the Page.Load event). It's ok to have two event handlers
wired up to the same event.

Does that make sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Tue, 19 Apr 2005 11:58:03 -0700, "Alex"
<(E-Mail Removed)> wrote:

>Can you provide with a little more detail on how I can achieve it. Maybe some
>additional keywords I can search on?I don't understand how I can achieve this.
>
>"Scott Allen" wrote:
>
>> Alex:
>>
>> Your base form could also hook up to the Page_Load event, and both the
>> derived form and base form could have an event handler.
>>
>> --
>> Scott
>> http://www.OdeToCode.com/blogs/scott/
>>
>> On Mon, 18 Apr 2005 10:25:02 -0700, "Alex"
>> <(E-Mail Removed)> wrote:
>>
>> >We have a web site which we need to implement auditing. I've implemented a
>> >base form which all code behind files inherit from, and I can add the logic
>> >to it, but that would mean that all existing pages would need to be changed,
>> >and any future pages would need to also implement the call code.
>> >
>> >Is there a way to automatically call some code when a page_load has been
>> >invoked without adding code into the Page_Load? Global.asa would be nice, but
>> >I didn't find it usefull at a page level.

>>
>>


 
Reply With Quote
 
=?Utf-8?B?QWxleA==?=
Guest
Posts: n/a
 
      04-20-2005
Yes, thanks. I added this in InitializeComponent : this.Load += new
System.EventHandler(base.Page_Load);

The nice thing about this solution is that it's more scaleable since I can
keep on adding code in the base form if needed. The only downside is that we
need to remember to add the line in all of our forms, but I guess that's what
code reviews are for....
 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      04-20-2005
Ah, yes, but - you can add that line in the base form. Just override
OnInit and add the event handler for page load. OnInit is called by
the derived web form in the templated code VS.NET ceates for a new web
form.

With that in place you wouldn't need to remember to do anything in the
derived class.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 20 Apr 2005 05:15:02 -0700, "Alex"
<(E-Mail Removed)> wrote:

>Yes, thanks. I added this in InitializeComponent : this.Load += new
>System.EventHandler(base.Page_Load);
>
>The nice thing about this solution is that it's more scaleable since I can
>keep on adding code in the base form if needed. The only downside is that we
>need to remember to add the line in all of our forms, but I guess that's what
>code reviews are for....


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
in VB.NET Page_load of a base class called after the derived class Page_load ? z. f. ASP .Net 0 10-19-2004 12:01 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM
Re: Determinig what events will be called from Page_Load ??? John Saunders ASP .Net 4 08-22-2003 09:23 AM



Advertisments