CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/6/2007 1:16:37 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 327 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
aggiekevin
Asp.Net User
Page_PreInit & OnPreInit - whats the difference?4/6/2007 1:16:37 AM

0

I'm trying to figure out the difference between the Page_PreInit method and the OnPreInit method. I am writing some logic to enable users to switch themes and skins on my site. I know this sort of thing must be done in the pre-initialization stage of the page, but I don't understand what the difference is between these two methods.

 

Thanks 


thanks and gig 'em!

--aggiekevin|07--
JMayo
Asp.Net User
Re: Page_PreInit &amp; OnPreInit - whats the difference?4/6/2007 3:23:44 AM

0

Hi Kevin,

The Page_PreInit method is an event handler, but the OnPreInit method is an override.  You can use either of them without a problem.  When the PreInit event is raised in the page lifecycle, ASP.NET calls OnPreInit in the Page class.  Since OnPreInit is virtual, your OnPreInit override is called polymorphically.  It is good practice to call base.OnPreInit (or call the base class on any of the overrides) to ensure the base class has an opportunity to process the event.  Page_PreInit is called automatically if you have AutoEventWireup set to true, which is now set automatically whenever you create a page.  It is simply a handler for the PreInit event.  This is an event-based method, as opposed to the object-oriented approach to handling the PreInit event.  I tend to use the Page_Xxx methods rather than the OnXxx overrides because of convention, knowing that they'll be easily recognizable and understood by most ASP.NET developers.  Other than that, don't have a strong opinion one way or the other as to which is best. 

Joe


Free C# Tutorials at C# Station
aggiekevin
Asp.Net User
Re: Page_PreInit & OnPreInit - whats the difference?4/6/2007 7:47:57 AM

0

Thanks for the explanation!

thanks and gig 'em!

--aggiekevin|07--
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Page_PreInit & OnPreInit - whats the difference? - ASP.NET Forums I'm trying to figure out the difference between the Page_PreInit method and the OnPreInit method. I am writing some logic to enable users to switch themes ...
[Mono-bugs] [Bug 77278][Nor] New - Setting masterpage in OnPreInit ... OnInit(e); + + + +} + + +private void Page_PreInit (object sender ... +
+ What's inside the following ...
Page_PreInit no execute in MasterPage Adding method Page_PreInit doesn't also mean that there is an event named ... protected override OnPreInit(...), the compiler will not accept it. To solve your issue, ... Dumb non-programmer question--what's redir.asp? ...
Oren Ellenbogen's Blog - Override OnPreInit on a Page with Master ... Feb 7, 2007 ... What's hot ? (and I mean really ...) - scroll down for more ... made me realize that I need to do my magic on the page's PreInit event. ...
Infinities Loop: ViewState: Misunderstood monster or fluffy ... Feb 9, 2006 ... What's wrong is HOW you make it the default value. ... Its a very... subtle... difference. But its VERY IMPORTANT! ... NET 2.0 provides the OnPreInit event which I thought was seriously lacking in 1.x, and you can set them safely in there ... void Page_PreInit(object sender, EventArgs e) { ...

Page_PreInit & OnPreInit - whats the difference? - ng.asp-net ... Page_PreInit & OnPreInit - whats the difference?, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls, ...
Invalid postback or callback argument requiring ... page_preinit & onpreinit - whats the difference? order that css is added to the master page & content pages. ...
Databinding expressions are only supported on objects that have a ... page_preinit & onpreinit - whats the difference? user.identity.isauthenticated doesn't work in master page · how do i reference a gridview column in a .skin ...
ASP:Menu - Make Entire sub-menu item clickable? - ng.asp-net-forum ... page_preinit & onpreinit - whats the difference? populate current date in master page · masterpage - content page formatting help... asp 2.0 menu postback ...
AutoEventWireup=False stops dynamic master page attempt - ng.asp ... protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); } is equivalent to






[treeview] how to set font=bold for root node without child node?

seo and viewstate of master pages

treeview , same code , different behavior

master & content page

master page and content page event handling

problem in using both staticsitemapprovider and web.sitemap

how to get the list of themes?

classic .asp site in content page - can it be done?

panel.defaultbutton, form.defaultbutton and templated buttons inside a detailsview

asp.net 2.0 menu interferes with scrolling div

how to use master with multiple contentplaceholders

regarding master page in asp.net 2.0

seo question about masterpages

setting defaultbutton for panel on a webform that using masterpages

treeview like msdn

multiple site map files

div height issues with screen layout

advanced menu creation

help a newb "update a labels text on a masterpage from a content page" please.

how to access the navigateurl of child of treeview in masterpage to content page?

master page with user control causes master page_load to fire twice!

how do i get master page's controls value into content page!!!

roles in sitemapnode

horizontal menu with fixed width cells?

calling master page method from user control

wizard question

scrolling position of the treeview resets on postback to the server

dynamic loading of masterpage

problem with a page that isn't included in web.sitemap

menu control on master page

   
  Privacy | Contact Us
All Times Are GMT