By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,685 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,685 IT Pros & Developers. It's quick & easy.

Where is Page_Unload event?

P: n/a
Hi there,
I'm using Web Developer Express 2005 in my ASP.NET learning.
I tried creating a simple aspx page using "code-behind" approach. I noticed
that protected void Page_Load event method appears automatically in
mypage.aspx.cs
Ok, so far so good, but now I need to code something when Page_Unload occurs
but I can't find a place to choose or select Page_Unload event.

I'm asking this because I created a mypage2.aspx using "single-file"
approach: layout and code in my single file mypage2.aspx and if I click on
the dropdown list above the code-editor area these are the items:
Server Objects & Events
Page
form1
Server Code
Client Objects & Events
document
form1
window
Client Script

then I choose Page and at the dropdown list on the right I choose Unload and
my script becomes in this:
<script runat="server">
protected void Page_Unload(object sender, EventArgs e)
{

}
</script>

this way I'm able to put code in Page_Unload event.

How can I do this using "code-behind" approach?
Do I have to hard code it by-hand?
If this is the case, which advantages bring me the "code-behind" approach if
I'm not able to "access" all events from Server controls?

Thanks a lot, I really appreciate it
Best Regards
Jun 1 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You can wire a routine to the Unload event of hte Page class. In VB it is
Handles this.Load. In C#, you have to wire the delegate to the event.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
Hi there,
I'm using Web Developer Express 2005 in my ASP.NET learning.
I tried creating a simple aspx page using "code-behind" approach. I
noticed
that protected void Page_Load event method appears automatically in
mypage.aspx.cs
Ok, so far so good, but now I need to code something when Page_Unload
occurs
but I can't find a place to choose or select Page_Unload event.

I'm asking this because I created a mypage2.aspx using "single-file"
approach: layout and code in my single file mypage2.aspx and if I click on
the dropdown list above the code-editor area these are the items:
Server Objects & Events
Page
form1
Server Code
Client Objects & Events
document
form1
window
Client Script

then I choose Page and at the dropdown list on the right I choose Unload
and
my script becomes in this:
<script runat="server">
protected void Page_Unload(object sender, EventArgs e)
{

}
</script>

this way I'm able to put code in Page_Unload event.

How can I do this using "code-behind" approach?
Do I have to hard code it by-hand?
If this is the case, which advantages bring me the "code-behind" approach
if
I'm not able to "access" all events from Server controls?

Thanks a lot, I really appreciate it
Best Regards

Jun 1 '07 #2

P: n/a
Thanks a lot for your reply Gregory.
Ok, this means that there's no "graphical" way to add the delegate to
Page_Unload event?

I really want to start projects using "code-behind" approach.

Best Regards
"Cowboy (Gregory A. Beamer)" wrote:
You can wire a routine to the Unload event of hte Page class. In VB it is
Handles this.Load. In C#, you have to wire the delegate to the event.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
Hi there,
I'm using Web Developer Express 2005 in my ASP.NET learning.
I tried creating a simple aspx page using "code-behind" approach. I
noticed
that protected void Page_Load event method appears automatically in
mypage.aspx.cs
Ok, so far so good, but now I need to code something when Page_Unload
occurs
but I can't find a place to choose or select Page_Unload event.

I'm asking this because I created a mypage2.aspx using "single-file"
approach: layout and code in my single file mypage2.aspx and if I click on
the dropdown list above the code-editor area these are the items:
Server Objects & Events
Page
form1
Server Code
Client Objects & Events
document
form1
window
Client Script

then I choose Page and at the dropdown list on the right I choose Unload
and
my script becomes in this:
<script runat="server">
protected void Page_Unload(object sender, EventArgs e)
{

}
</script>

this way I'm able to put code in Page_Unload event.

How can I do this using "code-behind" approach?
Do I have to hard code it by-hand?
If this is the case, which advantages bring me the "code-behind" approach
if
I'm not able to "access" all events from Server controls?

Thanks a lot, I really appreciate it
Best Regards


Jun 1 '07 #3

P: n/a
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
I really want to start projects using "code-behind" approach.
So what's stopping you...?
--
http://www.markrae.net

Jun 2 '07 #4

P: n/a
I already replied to you in the spanish-language asp.net newsgroup,
but for the benefit of those who post here and not there, there's a code example at :

http://www.velocityreviews.com/forum...nd-module.html


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
Thanks a lot for your reply Gregory.
Ok, this means that there's no "graphical" way to add the delegate to
Page_Unload event?

I really want to start projects using "code-behind" approach.

Best Regards
"Cowboy (Gregory A. Beamer)" wrote:
>You can wire a routine to the Unload event of hte Page class. In VB it is
Handles this.Load. In C#, you have to wire the delegate to the event.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

*********************************************** *
Think outside the box!
*********************************************** *
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:3C**********************************@microso ft.com...
Hi there,
I'm using Web Developer Express 2005 in my ASP.NET learning.
I tried creating a simple aspx page using "code-behind" approach. I
noticed
that protected void Page_Load event method appears automatically in
mypage.aspx.cs
Ok, so far so good, but now I need to code something when Page_Unload
occurs
but I can't find a place to choose or select Page_Unload event.

I'm asking this because I created a mypage2.aspx using "single-file"
approach: layout and code in my single file mypage2.aspx and if I click on
the dropdown list above the code-editor area these are the items:
Server Objects & Events
Page
form1
Server Code
Client Objects & Events
document
form1
window
Client Script

then I choose Page and at the dropdown list on the right I choose Unload
and
my script becomes in this:
<script runat="server">
protected void Page_Unload(object sender, EventArgs e)
{

}
</script>

this way I'm able to put code in Page_Unload event.

How can I do this using "code-behind" approach?
Do I have to hard code it by-hand?
If this is the case, which advantages bring me the "code-behind" approach
if
I'm not able to "access" all events from Server controls?

Thanks a lot, I really appreciate it
Best Regards



Jun 2 '07 #5

P: n/a
So what's stopping you...?
Nothing, I'm just beginning to code using "code-behind" approach. It is just
that I wanted to clear a doubt I had about the "graphical" way to add
delegates using this approach.

Thanks.
"Mark Rae" wrote:
"Rolandpish" <Ro********@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
I really want to start projects using "code-behind" approach.

So what's stopping you...?
--
http://www.markrae.net

Jun 3 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.