472,780 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 6169
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.