473,385 Members | 2,243 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,385 software developers and data experts.

Visual Studio and PreInit handler

WT
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
Feb 12 '07 #1
8 6234
That doesn't sound right.....maybe your ASP.NET templates got messed up?

What does it look like?

karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"WT" <WT@newsgroups.nospamwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
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
Feb 12 '07 #2
WT
Hi Karl, Thanks for answer, where to check this template ?
CS
"Karl Seguin [MVP]" <ka********@removeopenmymindremovemetoo.andmenet a
écrit dans le message de news: ev**************@TK2MSFTNGP04.phx.gbl...
That doesn't sound right.....maybe your ASP.NET templates got messed up?

What does it look like?

karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"WT" <WT@newsgroups.nospamwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
>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

Feb 12 '07 #3
Hello CS,

Do you mean when you use Visual Studio to develop ASP.NET 2.0 web page, the
IDE automatically add the "PreInit" handler's registering code in "OnInit"
function?

Generally, for ASP.NET 2.0 web pages, since the "AutoWireupEvent" is set to
"true", we simply add the event handler function in codebehind(with the
expected naming convention) and the runtime will automatically attach the
handler to the page's corresponding event. e.g.
public partial class nav_menupage : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("<br/>Page_PreInit.....");
}

....................
}
Is this behavior not working in your development environment?

Please feel free to let me know your detailed scenario so that we can
perform some further research on this.

Look forward to your reply.

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 #4
WT
Hello Steven,

Yes, the IDE is generating the PreInit in OnInit, more prcesely in the
InitializeComponent that is sent by preInit.
My projet is a Web Application, I am using Visual Studio Pro with SP1 on a
XP laptop, using C#, following are informations from VS.

For majority of my aspx pages AutoEventWireUp is turned off.
I followed this process: open the aspx page, choose Design mode, then from
right click menu choose View Component Designer (I have not found another
way to display the page properties with handlers), then right click again
and Properties, then Events button, then double click in the PreInit.
Switcing back to the code windows, I cans see the generated code:

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.PreInit += new System.EventHandler(this.DesktopDefault_PreInit);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void DesktopDefault_PreInit(object sender, EventArgs e)

{

}

It seems a bug.

Here are My VS infos.

Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual Basic 2005 77626-009-0000007-41381
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 77626-009-0000007-41381
Microsoft Visual C# 2005

Microsoft Visual Studio Tools for Office 77626-009-0000007-41381
Microsoft Visual Studio Tools for the Microsoft Office System

Microsoft Visual Web Developer 2005 77626-009-0000007-41381
Microsoft Visual Web Developer 2005

Microsoft Web Application Projects 2005 77626-009-0000007-41381
Microsoft Web Application Projects 2005
Version 8.0.50727.762

Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005
Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1
(KB926601)
This service pack is for Microsoft Visual Studio 2005 Professional Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/926601

SQL Server Analysis Services
Microsoft SQL Server Analysis Services Designer
Version 9.00.2047.00

SQL Server Integration Services
Microsoft SQL Server Integration Services Designer
Version 9.00.1399.00

SQL Server Reporting Services
Microsoft SQL Server Reporting Services Designers
Version 9.00.1399.00

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

Do you mean when you use Visual Studio to develop ASP.NET 2.0 web page,
the
IDE automatically add the "PreInit" handler's registering code in "OnInit"
function?

Generally, for ASP.NET 2.0 web pages, since the "AutoWireupEvent" is set
to
"true", we simply add the event handler function in codebehind(with the
expected naming convention) and the runtime will automatically attach the
handler to the page's corresponding event. e.g.
public partial class nav_menupage : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("<br/>Page_PreInit.....");
}

....................
}
Is this behavior not working in your development environment?

Please feel free to let me know your detailed scenario so that we can
perform some further research on this.

Look forward to your reply.

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 #5
Thanks for your reply CS,

I've performed some tests in my local environment, also a XP/sp2 box with
vs 2005 SP1 installed. However, the result I got is a bit different. When I
select and double click to generate an event handler (for PreInit for
instance), it did add the "InitializeComponent" function and with the code
that register the handler, however, the difference is that the "OnInit"
method is not generated and the "InitializeComponent" method is not called
by any other function.

Here is the complete generated code (codebehind and codebehind.designer...)
in my test environment:

==========codebehind==============
namespace TestWebAppProj
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

private void InitializeComponent()
{
this.PreInit += new System.EventHandler(this._Default_PreInit);

}

private void _Default_PreInit(object sender, EventArgs e)
{

}
}
}
====================================

==========codebehind.designer==================

namespace TestWebAppProj
{

public partial class _Default
{
protected System.Web.UI.HtmlControls.HtmlForm form1;
}
}
=============================================

Have you tested on some other box with VS 2005 SP1installed to see whether
they have the same behavior?

Sincerely,

Steven Cheng

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



Feb 14 '07 #6
WT
Heloo Steven,

Thanks again for feedback.
Concerning your question, I am actually porting 1.1 code to 2 and in
majority of files the OnInit handler exist because we are with
AutoEventWireup=false.
And when the InitializeComponent is already existing and called inside
OnInit, then VS does no check for this and adds it delegate in
InitializeComponent which is badly called.
Seems a problem.

CS

"Steven Cheng[MSFT]" <st*****@online.microsoft.coma écrit dans le message
de news: Jm*************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply CS,

I've performed some tests in my local environment, also a XP/sp2 box with
vs 2005 SP1 installed. However, the result I got is a bit different. When
I
select and double click to generate an event handler (for PreInit for
instance), it did add the "InitializeComponent" function and with the code
that register the handler, however, the difference is that the "OnInit"
method is not generated and the "InitializeComponent" method is not called
by any other function.

Here is the complete generated code (codebehind and
codebehind.designer...)
in my test environment:

==========codebehind==============
namespace TestWebAppProj
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

private void InitializeComponent()
{
this.PreInit += new System.EventHandler(this._Default_PreInit);

}

private void _Default_PreInit(object sender, EventArgs e)
{

}
}
}
====================================

==========codebehind.designer==================

namespace TestWebAppProj
{

public partial class _Default
{
protected System.Web.UI.HtmlControls.HtmlForm form1;
}
}
=============================================

Have you tested on some other box with VS 2005 SP1installed to see whether
they have the same behavior?

Sincerely,

Steven Cheng

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





Feb 14 '07 #7
Thanks for your followup CS,

So I've understood your complete scenario. Yes, VS 2003/asp.net 1.1 project
used to put the "InitializeComponents" function call in OnInit method(for
C#). It is obviously that this behavior is incorrect for VS 2005/asp.net
2.0 project since we need to put it in earlier event. I think put it in
class's constructor should be ok.

I think this one of those convertion problems that need to be improved for
the Web Application project. You're encouraged to submit such issues to the
feedback center so that the dev team can hear more on this.

http://connect.microsoft.com/feedbac...spx?SiteID=210

Thanks for your feedback and comments.

Sincerely,

Steven Cheng

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

Feb 15 '07 #8
WT
Reported.
CS
"Steven Cheng[MSFT]" <st*****@online.microsoft.coma écrit dans le message
de news: S2**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your followup CS,

So I've understood your complete scenario. Yes, VS 2003/asp.net 1.1
project
used to put the "InitializeComponents" function call in OnInit method(for
C#). It is obviously that this behavior is incorrect for VS 2005/asp.net
2.0 project since we need to put it in earlier event. I think put it in
class's constructor should be ok.

I think this one of those convertion problems that need to be improved for
the Web Application project. You're encouraged to submit such issues to
the
feedback center so that the dev team can hear more on this.

http://connect.microsoft.com/feedbac...spx?SiteID=210

Thanks for your feedback and comments.

Sincerely,

Steven Cheng

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

Feb 16 '07 #9

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

Similar topics

0
by: Joel Just Joel | last post by:
Good day, dotnet.general Folks, I'm not sure if this is the correct forum for posting general Visual Studio ..NET questions, but I hope so. If not, please forgive and tell me where to post...
0
by: JDeats | last post by:
I'm trying to create a Visual Studio.NET Add-in. I'm using the wizard provided by VS.NET. I have Visual Studio.NET Enterprise Architect edition and I've selected New->Projects->Other...
0
by: Noulouk | last post by:
Hi, I build an add-in for Visual Studio 2005. I use the wizzard, I fixed the bug with envdte reference and build my project immediately after the wizzard. All seems to work, the add-in is shown...
2
by: Justin Beckwith | last post by:
Hey all, to keep some common functionality together, I am making all of my web forms inherit from one base class, which inherits from System.Web.UI.Page, instead of all my webforms inheriting...
0
by: Dr. Zharkov | last post by:
Hello. To see the graphics of technology DirectX 9.0 SDK Update - June 2005 in project Visual Basic, WindowsApplication1 from Visual Studio 2005 Beta 1, in file My Project, MyApplication.vb in a...
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...
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); ...
2
by: Ilyas | last post by:
Hi all I have a simple httphandler : public class TextFileHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain";...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.