Init Event on tha Page

A

andrea rosa

Hi folks,

I've got a question regarding the managment of the events in a
System.Web.UI.Page.
If I want to write code for this event in my code behind I have to
write something like that:
protected void Page_Init(object sender, EventArgs e)

That works but I don't understand why!!!

How the .Net framework understand that this is the handler of the event
Init?!?!?
For all the others controls I must use the properties windows to set
the right event handler, but I can't do it with the page...
I'm a little confused, someone can help me?
Best
 
D

Dave Sexton

Hi Andrea,
I've got a question regarding the managment of the events in a
System.Web.UI.Page.
If I want to write code for this event in my code behind I have to
write something like that:
protected void Page_Init(object sender, EventArgs e)

That works but I don't understand why!!!

How the .Net framework understand that this is the handler of the event
Init?!?!?

The event handler is hooked-up automatically by ASP.NET since it uses a
particular naming convention. The AutoEventWireup attribute of the @Page
directive controls this behavior:

ASP.NET Web Server Control Event Model
§ Binding Page Events
http://msdn2.microsoft.com/en-us/library/y3bwdsh3(VS.80).aspx
For all the others controls I must use the properties windows to set
the right event handler, but I can't do it with the page...
I'm a little confused, someone can help me?

IIRC you can do that with Pages as well. In the Properties Window select
the Page from the drop-down list at the top. You might not be able to focus
the Page by clicking in the designer, however.
 
A

andrea rosa

Hi Dave,

Thanks for your reply,

now It's clear how the implicit binding for page events works.
The event handler is hooked-up automatically by ASP.NET since it uses a
particular naming convention. The AutoEventWireup attribute of the @Page
directive controls this behavior:

ASP.NET Web Server Control Event Model
§ Binding Page Events
http://msdn2.microsoft.com/en-us/library/y3bwdsh3(VS.80).aspx


IIRC you can do that with Pages as well. In the Properties Window select
the Page from the drop-down list at the top. You might not be able to focus
the Page by clicking in the designer, however.

I haven't found it ...but that's not important.[/QUOTE]
 

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

Top