page events in C# INIT-LOAD-PRE-RENDER

M

mesut

Hi colleagues,

how are the page events handled in C#? In VB you have the handles
keyword. and in C# all the params (object and EventArgs ) are the same
for 3 eventhandlers below.
a- How does the framework know which one is page_load, and which one
is PreRender?
Is it because of the name?
b- If I would like to add these events in C# code behind, what is the
trick. I just copy and paste it. In VB you can select from
dropdownlistboxes?

thanks for any advice,

cheers,
mesut


(1)
protected void Page_PreRender(object sender, EventArgs e)
//--------------------------------------------------------------------------
{
do somethig
}
(2)
//--------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
do something
}
(3)
protected void Page_Init(object sender, EventArgs e)
{
}
 
M

Michael Nemtsev

Hello mesut,

Firstly, this question is more appropriate to asp.net group

m> a- How does the framework know which one is page_load, and which one
m> is PreRender? m> Is it because of the name?

each page in asp.net 2.0 has the AutoEventWireup tag set to true, which means
that all this page event initialization are made explicitly for u.

m> b- If I would like to add these events in C# code behind, what is the
m> trick. I just copy and paste it. In VB you can select from
m> dropdownlistboxes?

just select the page or the control and set the handler for the desired event
in the properties manually
---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
 
M

mesut

Hi Michael,

sorry if it was wrong group. I just started learning C# and I thought
I could post the question to this group because of C#, but you're
right it's more asp.net question.
your first answer: but how does the system now
that this protected void Page_PreRender(object sender, EventArgs e)
is PAGE_PRERENDER
and this is protected void Page_Load(object sender, EventArgs e) is
PAGE LOAD
etc.
is it because of the name?

thanks for your answers. If you don't answer no harm. thanks anyway...
I'll post it to other group then.

cheers, mesut
 
M

Michael Nemtsev

Hello mesut,

have u read this http://msdn2.microsoft.com/en-us/library/system.web.configuration.pagessection.autoeventwireup.aspx
?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


m> Hi Michael,
m>
m> sorry if it was wrong group. I just started learning C# and I thought
m> I could post the question to this group because of C#, but you're
m> right it's more asp.net question.
m> your first answer: but how does the system now
m> that this protected void Page_PreRender(object sender, EventArgs e)
m> is PAGE_PRERENDER
m> and this is protected void Page_Load(object sender, EventArgs e) is
m> PAGE LOAD
m> etc.
m> is it because of the name?
m> thanks for your answers. If you don't answer no harm. thanks
m> anyway... I'll post it to other group then.
m>
m> cheers, mesut
m>
 

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