473,382 Members | 1,420 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,382 software developers and data experts.

AutoEventWireup and PreInit

WT
Hello,
It seems that Page_PreInit is not run automatically when AutoEventWireUp is
set for the Page as it is for Page_Load or Page_Init.

Somebody could confirm this missing point ?

CS
Feb 12 '07 #1
5 7952
Hello CS,

I've also seen your another thread "Visual Studio and PreInit handler" and
have posted in there. Is the problem here the same one as that thread?

As I've mentioned in that thread, for ASP.NET 2.0 page, as long as you set
the "AutoWireupEvent" to "true", you only need to put the correct named
page event handler function in codebehind and the runtime should
automatically register the event handler for you. And the "PreInit" is
surely of this case.

==============
public partial class nav_menupage : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("<br/>Page_PreInit.....");
}
.............
==============

Is there anything incorrect in the PreInit handler's definition or any
other programmatic code whch has turned of the "AutoEventWireup"?

BTW, for MasterPage and ascx usercontrol, they do not have "PreInit" event,
therefore, you should not put PreInit event handler in these two
components' codebehind.

Please feel free to let me know if there is anything else particular in
your scenario.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 13 '07 #2
WT
Steven,

My oiher thread is another problem.
Ok I was trying to use Page_PreInit in an ascx file.
I have switched to the property setting method after LoadControl you
suggested in another thread
I have moved the LoadControl in the PreInitEvent of the Page and it seems to
be Ok.

What I would ideally appreciated is to understand the detailled differences
in the Page and its Controls objects between the OnPreInit Step, the OnInit
step and the OnLoad.

Regards
CS
"Steven Cheng[MSFT]" <st*****@online.microsoft.coma écrit dans le message
de news: o3**************@TK2MSFTNGHUB02.phx.gbl...
Hello CS,

I've also seen your another thread "Visual Studio and PreInit handler" and
have posted in there. Is the problem here the same one as that thread?

As I've mentioned in that thread, for ASP.NET 2.0 page, as long as you set
the "AutoWireupEvent" to "true", you only need to put the correct named
page event handler function in codebehind and the runtime should
automatically register the event handler for you. And the "PreInit" is
surely of this case.

==============
public partial class nav_menupage : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("<br/>Page_PreInit.....");
}
............
==============

Is there anything incorrect in the PreInit handler's definition or any
other programmatic code whch has turned of the "AutoEventWireup"?

BTW, for MasterPage and ascx usercontrol, they do not have "PreInit"
event,
therefore, you should not put PreInit event handler in these two
components' codebehind.

Please feel free to let me know if there is anything else particular in
your scenario.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 13 '07 #3
"WT" <WT@newsgroups.nospamwrote in message
news:O$**************@TK2MSFTNGP04.phx.gbl...
What I would ideally appreciated is to understand the detailled
differences in the Page and its Controls objects between the OnPreInit
Step, the OnInit step and the OnLoad.
This is well enough documented...
http://www.codeproject.com/useritems/lifecycle.asp
Feb 13 '07 #4
Thanks for your quick reply CS,

You can get a full list of the events available in UserControl here:

#UserControl Events
http://msdn2.microsoft.com/en-us/library/d6thxdk7.aspx

The reason why UserControl(also Control, WebControl) doesn't have the same
event collection as Page is because controls are loaded at a certain stage
in Page's lifecycle, this determines that Control's lifecycle certainly
begin after Page has done some certain intialization, so there are some
ealier events in Page's lifecycle which is not available to Web controls.
For example, at Page's PreInit stage, those child controls are not even
created and initialized(participate in the page processing pipeline), they
surely won't be able to utlize the "PreInit" event.

Here are two good msdn reference which are very helpful on understanding
the ASP.NET page and control's server-side process stages:

#ASP.NET Page Life Cycle Overview
http://msdn2.microsoft.com/en-us/library/ms178472.aspx

#Control Execution Lifecycle
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconControlExecutionLifecycle.asp

If you have any further questions on this, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Feb 13 '07 #5
WT
Thanks, excatly what I was searching for, I was still on NET 1.1 timeframe.
CS
"Mark Rae" <ma**@markNOSPAMrae.coma écrit dans le message de news:
uX**************@TK2MSFTNGP02.phx.gbl...
"WT" <WT@newsgroups.nospamwrote in message
news:O$**************@TK2MSFTNGP04.phx.gbl...
>What I would ideally appreciated is to understand the detailled
differences in the Page and its Controls objects between the OnPreInit
Step, the OnInit step and the OnLoad.

This is well enough documented...
http://www.codeproject.com/useritems/lifecycle.asp

Feb 13 '07 #6

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

Similar topics

28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
2
by: shapper | last post by:
Hello, I need to set, at runtime, MyLabel.SkinID="MySkinID". I know this must be done in Page PreInit event. However, MyLabel is in my Master Page. I tried to add the Page PreInit event...
1
by: needin4mation | last post by:
I have this code. The preinit never fires: public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Label1.Text...
6
by: Rahul | last post by:
this is my code in preinit event I have "hlinkAdd" as hyperlink web control and i am using a master page, and below code is of content page preinit event. Protected Sub Page_PreInit(ByVal sender...
0
by: Rahul | last post by:
this is my code in preinit event I have "hlinkAdd" as hyperlink web control and i am using a master page, and below code is of content page preinit event. Protected Sub Page_PreInit(ByVal sender...
8
by: WT | last post by:
Is it normal that Visual Studio sets the PreInit handler for a Page from the OnInit code ? No chance to fire it as OnPreInit is run befor OnInit. ??? CS
3
by: Morgan Cheng | last post by:
"Server.Transfer(Request.FilePath);" make server re-evaluate current page. In debugger, I found that though the page's OnPreInit is called, delegates attached in HttpModule is not executed. Why...
0
by: ThomasEmpl | last post by:
Hello, I have a Webcustom Control and am trying to override the PreInit function ... public MyControl() { this.Page.PreInit += new EventHandler(Page_PreInit); ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...

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.