473,796 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autotmate Page_load events

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.
Nov 19 '05 #1
5 1399
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"
<Al**@discussio ns.microsoft.co m> 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.


Nov 19 '05 #2
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"
<Al**@discussio ns.microsoft.co m> 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.


Nov 19 '05 #3
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"
<Al**@discussio ns.microsoft.co m> 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"
<Al**@discussio ns.microsoft.co m> 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.



Nov 19 '05 #4
Yes, thanks. I added this in InitializeCompo nent : this.Load += new
System.EventHan dler(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....
Nov 19 '05 #5
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"
<Al**@discussio ns.microsoft.co m> wrote:
Yes, thanks. I added this in InitializeCompo nent : this.Load += new
System.EventHa ndler(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....


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2537
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the site into consideration. Here is what I want to do: I have a Button, which starts a new search session. When this session is started, you have several Usercontrols, which can navigate within the search session.
6
2399
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for postback. Here's the deal : From now on, I set CurrentThread.CurrentCulture only during PageLoad. so date and currency format is incorrect if page load is not called first. What should I do to ensure that CurrentThread.CurrentCulture is alway set...
2
1881
by: John Dalberg | last post by:
I need to know what happens after Page_load has finished so I put a breakpoint at the last statement. However after stepping into after this last statement, the app continues running without the debugger. Why can't I single step until the screen has fully rendered? -- John Dalberg
1
1129
by: tshad | last post by:
One of the differences with building one page style in DW and code behind in VS 2003 is you have to declare the events (apparently). For some reason my events will disapper. For example: I have the the following events in my InitializeComponents section: this.Load += new System.EventHandler(this.Page_Load);
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.