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

ASP.NET Page Inheritence and Visual Studio

P: n/a
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
System.Web.UI.Page. To inherit the base class, my page load method
should NOT handle the base class event, since the method I am
overloading in the base class handles the page load event. So I
deleted the event handler, and all was working well. However, when I
close and re-open the web form in Visual Studio, it appends the
"Handles MyBase.Load" clause to the end of my Page_Load method. Has
anyone ever run into this before?
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Why do you want to do this? I just played with a BasePage for the first
time yesterday. I wanted all my pages to run the same code in Page_Load, so
I added it to a BasePage class. Each derived class still has their own
Page_Load events that runs. Why don't you want the derived classes's
Page_Load events to run? Can't you just leave the event empty?

Or am I just missing what you are trying to do? :^)

Here is my BasePage class:

Public Class BasePage
Inherits Page

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.Cache.SetCacheability(HttpCacheability.No Cache)

End Sub
End Class

PS: In the future I would post to microsoft.public.dotnet.aspnet group.

Greg

"Justin Beckwith" <pi*******@yahoo.com> wrote in message
news:4a**************************@posting.google.c om...
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
System.Web.UI.Page. To inherit the base class, my page load method
should NOT handle the base class event, since the method I am
overloading in the base class handles the page load event. So I
deleted the event handler, and all was working well. However, when I
close and re-open the web form in Visual Studio, it appends the
"Handles MyBase.Load" clause to the end of my Page_Load method. Has
anyone ever run into this before?

Nov 21 '05 #2

P: n/a
Not thinking, everytime I double clicked the form to get to the
codebehind, the default action of the form control was re-creating the
event handler for the page load method. Instead of handling the event
in the base class, I am handling it on the client, and that seems to
be working fine, as long as I make a call to MyBase.Page_Load.
Thanks!

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message news:<eh**************@TK2MSFTNGP12.phx.gbl>...
Why do you want to do this? I just played with a BasePage for the first
time yesterday. I wanted all my pages to run the same code in Page_Load, so
I added it to a BasePage class. Each derived class still has their own
Page_Load events that runs. Why don't you want the derived classes's
Page_Load events to run? Can't you just leave the event empty?

Or am I just missing what you are trying to do? :^)

Here is my BasePage class:

Public Class BasePage
Inherits Page

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.Cache.SetCacheability(HttpCacheability.No Cache)

End Sub
End Class

PS: In the future I would post to microsoft.public.dotnet.aspnet group.

Greg

"Justin Beckwith" <pi*******@yahoo.com> wrote in message
news:4a**************************@posting.google.c om...
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
System.Web.UI.Page. To inherit the base class, my page load method
should NOT handle the base class event, since the method I am
overloading in the base class handles the page load event. So I
deleted the event handler, and all was working well. However, when I
close and re-open the web form in Visual Studio, it appends the
"Handles MyBase.Load" clause to the end of my Page_Load method. Has
anyone ever run into this before?

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.