Where is Init() & InitializeComponent()?

J

john_c

When I add a new aspx page to my project, I don't see Init() or
InitializeComponent() in any of the page's CS files. Where are the
methods stored?

Thanks.
 
G

Guest

They are contained in a #region in your form's code behind .cs file annotated
"Web Form Designer generated code" which by default is minimized in Visual
Studio. Just click the plus sign to the left of "Web Form Designer generated
code" to expand the region and see the code.
 
G

Guest

John and Jim,

MST changed default designing/compilation model in ASP.NET 2.0. By default
AutoEventWireup is set to true, which instructs compiler to automatically
attach event handlers from the code behind/beside file using naming
convention (for the page events) i.e.
protected void Page_Load(...)
{
}
is automatically attached behind the scenes:
this.Load += new EventHandler(this.Page_Load)

or controls declarative properties:

<asp:GridView runat="server" id="gv" OnRowDataBound="myeventhandlername"/>
is resolved by compiler as:
gv.RowDataBound += new RowDataBoundEventHandler(this.myeventhandlername);

Hope this helps
 
J

john_c

these are no longer required in asp.net 2.0.

I am using asp.net 2.0. If I set AutoEventWireUp=false, do I need to
wireup Init() in the page or control constructor?

if I only have perhaps 3 - 5 events, is it better to keep
AutoEventWireUp=false since I don't need everything else it will be
doing? Is there a demarcation point or something to know when it
should be used? I'm only mentioning it because of performance.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top