473,770 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there Page_PreInit, but for the entire application?

Hi All,

Would anyone know if there is an event similar to the Page_PreInit that I
can code just once, at a global initialization level, that applies to all
pages executed?

Therefore, instead of placing the code below in every page codebehind, I
could code it just once.
Protected Sub Page_PreInit(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.PreInit

If Not Request.Browser .Browser.Contai ns("IE") Then

Me.ClientTarget = "uplevel"

End If

End Sub
Thanks

Edward Re
Oct 17 '06 #1
7 4212
"Edward" <aR******@hotma il.comwrote in message
news:lZ******** ***********@new s-server.bigpond. net.au...
Would anyone know if there is an event similar to the Page_PreInit that I
can code just once, at a global initialization level, that applies to all
pages executed?
There isn't.
Therefore, instead of placing the code below in every page codebehind, I
could code it just once.
Protected Sub Page_PreInit(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.PreInit

If Not Request.Browser .Browser.Contai ns("IE") Then

Me.ClientTarget = "uplevel"

End If

End Sub
Two main options:

1) Use MasterPages and ContentPages. However, since MasterPages don't have a
Page_PreInit event, you would need to create a base class which inherited
the Page object, create a Page_PreInit event in that, and then have your
MasterPages inherit the base class.

2) Do the above but without MasterPages i.e. create a base class with the
Page_PreInit code, and derive all your other pages from it.
Oct 17 '06 #2
The master page solution is a good one.

an HttpModule's BeginRequest might also do the trick (or you could just use
Global.asax's).

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:On******** ******@TK2MSFTN GP04.phx.gbl...
"Edward" <aR******@hotma il.comwrote in message
news:lZ******** ***********@new s-server.bigpond. net.au...
>Would anyone know if there is an event similar to the Page_PreInit that I
can code just once, at a global initialization level, that applies to all
pages executed?

There isn't.
>Therefore, instead of placing the code below in every page codebehind, I
could code it just once.
Protected Sub Page_PreInit(By Val sender As Object, ByVal e As
System.EventAr gs) Handles Me.PreInit

If Not Request.Browser .Browser.Contai ns("IE") Then

Me.ClientTarget = "uplevel"

End If

End Sub

Two main options:

1) Use MasterPages and ContentPages. However, since MasterPages don't have
a Page_PreInit event, you would need to create a base class which
inherited the Page object, create a Page_PreInit event in that, and then
have your MasterPages inherit the base class.

2) Do the above but without MasterPages i.e. create a base class with the
Page_PreInit code, and derive all your other pages from it.

Oct 17 '06 #3
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:eG******** ******@TK2MSFTN GP03.phx.gbl...
The master page solution is a good one.
That's the one I use.
an HttpModule's BeginRequest might also do the trick (or you could just
use Global.asax's).
Here's an article which describes this, albeit for a different purpose...
http://asp-net-whidbey.blogspot.com/...t-20-http.html

Interestingly enough, I've never actually got this to work properly - IIRC,
although the BeginRequest method does indeed fire before the PreInit method,
I never seemed to get access to the Page object at this stage...
Oct 17 '06 #4
re:
Would anyone know if there is an event similar to the Page_PreInit that I can code just once, at a
global initialization level, that applies to all pages executed?
There isn't one.
The good news is that you can build an httpmodule which will do the job for you.

See :
http://staff.develop.com/ballen/blog...c-13818fd75a56

Brock uses it to select a Theme, but you can modify the code to do what you want to do.

His sample code is at :
http://staff.develop.com/ballen/blog...hemeSample.zip

....but read his blog entry before attempting to use it.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Edward" <aR******@hotma il.comwrote in message
news:lZ******** ***********@new s-server.bigpond. net.au...
Hi All,

Would anyone know if there is an event similar to the Page_PreInit that I can code just once, at a
global initialization level, that applies to all pages executed?

Therefore, instead of placing the code below in every page codebehind, I could code it just once.
Protected Sub Page_PreInit(By Val sender As Object, ByVal e As System.EventArg s) Handles Me.PreInit

If Not Request.Browser .Browser.Contai ns("IE") Then

Me.ClientTarget = "uplevel"

End If

End Sub
Thanks

Edward Re


Oct 17 '06 #5
I sent in a suggestion before I read both of yours, which also do the work.

Brock's sample HttpModule code also works...


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message news:et******** ******@TK2MSFTN GP05.phx.gbl...
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME netwrote in message
news:eG******** ******@TK2MSFTN GP03.phx.gbl...
>The master page solution is a good one.

That's the one I use.
>an HttpModule's BeginRequest might also do the trick (or you could just use Global.asax's).

Here's an article which describes this, albeit for a different purpose...
http://asp-net-whidbey.blogspot.com/...t-20-http.html

Interestingly enough, I've never actually got this to work properly - IIRC, although the
BeginRequest method does indeed fire before the PreInit method, I never seemed to get access to
the Page object at this stage...

Oct 17 '06 #6
great! ... so many options to digest!

thanks everyone for your contribution
"Edward" <aR******@hotma il.comwrote in message
news:lZ******** ***********@new s-server.bigpond. net.au...
Hi All,

Would anyone know if there is an event similar to the Page_PreInit that I
can code just once, at a global initialization level, that applies to all
pages executed?

Therefore, instead of placing the code below in every page codebehind, I
could code it just once.
Protected Sub Page_PreInit(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.PreInit

If Not Request.Browser .Browser.Contai ns("IE") Then

Me.ClientTarget = "uplevel"

End If

End Sub
Thanks

Edward Re


Oct 17 '06 #7
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:eD******** ********@TK2MSF TNGP04.phx.gbl. ..
>I sent in a suggestion before I read both of yours
I believe you...:-)
Oct 17 '06 #8

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

Similar topics

2
1776
by: Earl Teigrob | last post by:
I am programming ASP.NET using C#. I have been accessing static variables accross my entire application but now need to change some of the static variables that are session specific to instance variables. (For more background, see previous post about 30 min ago) It was so cool using static variables because they where global to the entire application so I could calculate them when the page loaded and use then anywhere in the app. Now...
19
2758
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested in understanding as much as I can about how I can make this go as fast as possible on a linux system. I haven't run such a large database before. The nature of the database is such that
3
28053
by: Fred Nelson | last post by:
Hi Folks: I have a question about the Page_PreInit and Page_Load events in a web application. My question is: can I count on the Page_PreInit having completed before the Page_Load event starts. (I recall that someone told me in VS2003 that you could not count it!) I'm using C#.NET 2005 so if that was an issue in 2003, is it still an
9
3415
by: Lammert | last post by:
Good morning, I create an ASP.NET 2.0 web application. The situation: 1. One masterpage where the users can select an organisation in a DropDownList. 2. Different content pages. I will get the value of the DropDownList in the Page_PreInit event. How can I do that? The content in the content and master pages is based on
1
6887
by: ad | last post by:
Hi, I have set the this.Page.Theme in a MasterPage, but it no affect. I have set break point at this line, but it never execute. void Page_PreInit(object sender, System.EventArgs args) { this.Page.Theme = "Web"; }
0
1958
by: elphantasmo | last post by:
Hi, I have created a hosted AxWebBrowser control and I handle the NewWindow2 event to open new windows in my own forms. Our application accesses a JSF (Java Server Faces) backend with some custom controls created by Oracle (specifically a date/calendar popup to select a date). These custom controls behave in a strange way, i.e. they "fade" the parent window, make the child popup modal but apparently not by using "showModalDialog". It...
1
1190
by: Josh Naro | last post by:
I am writing a module that requires the entire output from a web app to perform its function. So, basically I need to be able to pull the entire output stream from the Response object. I've tried attaching a custom filter to Response.Filter, but the custom filter receives the stream in separate chunks. I need the entire stream at once in order to convert it to an XmlDocument. Does anyone know of a way to get the entire output stream from a...
1
1164
by: Finn Stampe Mikkelsen | last post by:
Hi Is there any intelligent way to similate windows function to show a map of the entire network visible to an application?? My job is this...: Picture a LAN/WLAN with 5 computers connected through a router. I need to run an application which as its first task needs to map out which other computers it can se in the network. Then it needs to 'ping' a certain port
18
5434
by: Redhairs | last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event during the postback?
0
9602
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...
1
10017
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
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
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...
0
6690
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();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
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
3
2832
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.