473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

ASP.Net: execute function on every page loaded?

Hi, all! Using ASP.Net (2.0 framework) with VB.Net code-behind...

Is there any way to execute a particular piece of code on each and every
page load in a website, without specifically putting that same code (or user
control) on each and every page? Some languages have a config file (like
application.cfm for Cold Fusion) that loads on every page where one can run
basic code on each page load, without adding code to each page.

Is there such a beastie with ASP.Net? I know that global.asax won't do the
trick...

Thanks for any suggestions!
Jack

Sep 20 '06 #1
3 5087
What exactly are you trying to do?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com

"JackBlack" <ja********@hotmail.comwrote in message
news:ei**************@TK2MSFTNGP05.phx.gbl...
Hi, all! Using ASP.Net (2.0 framework) with VB.Net code-behind...

Is there any way to execute a particular piece of code on each and every
page load in a website, without specifically putting that same code (or
user control) on each and every page? Some languages have a config file
(like application.cfm for Cold Fusion) that loads on every page where one
can run basic code on each page load, without adding code to each page.

Is there such a beastie with ASP.Net? I know that global.asax won't do
the trick...

Thanks for any suggestions!
Jack

Sep 20 '06 #2
JackBlack wrote:
Hi, all! Using ASP.Net (2.0 framework) with VB.Net code-behind...

Is there any way to execute a particular piece of code on each and every
page load in a website, without specifically putting that same code (or user
control) on each and every page?
Sure. You'll probably want to derive your own custom Page object, and
have all your pages use that as their base class.

So, step one is to create a new class called MyPage or whatever, based
on System.Web.UI.Page. Override the Page_Load method there to run your
common code, or create your own protected Initialize method that you'll
call from every page that needs it.

Next, base your codebehind classes off of MyPage rather than
System.Web.UI.Page. Problem solved.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Sep 20 '06 #3
Global.Asax do have a beginrrequest event ? You could also inherit from a
base page ? An httpModule ?

As John said, it's often more efficient to explain what you want to do. It
allows peers to give better advices (and perhaps sometimes a new approach to
the same problem).

--
Patrice

"JackBlack" <ja********@hotmail.coma écrit dans le message de news:
ei**************@TK2MSFTNGP05.phx.gbl...
Hi, all! Using ASP.Net (2.0 framework) with VB.Net code-behind...

Is there any way to execute a particular piece of code on each and every
page load in a website, without specifically putting that same code (or
user control) on each and every page? Some languages have a config file
(like application.cfm for Cold Fusion) that loads on every page where one
can run basic code on each page load, without adding code to each page.

Is there such a beastie with ASP.Net? I know that global.asax won't do
the trick...

Thanks for any suggestions!
Jack

Sep 20 '06 #4

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

Similar topics

7
by: Pavils Jurjans | last post by:
Hello, I wanted to get some light in the subject. As I develop ASP.NET applications, it's necessary to understand how exactly the server- communication happens. It seems like initially...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
5
by: Scott Natwick | last post by:
Is there a way to execute a JavaScript from the Page_Load event? Or alternatively, is there a way to have it execute when the page is loaded? I am defining the script in the Page_Load event and...
3
by: Tony | last post by:
Hi, I hope I can find answers to my questions here. 1. How to execute a Private Sub in VB, from a Javascript function event. 2. How to get a JavaScript Var value from the html page and return...
4
by: Jeremy Holt | last post by:
Hi, In a windows.forms application I would BeginInvoke a delegate on the UI thread to collect data from a database. When the call returns to the AsyncCallback, if the Control.InvokeRequired =...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.