PC Review


Reply
Thread Tools Rate Thread

ASP.NET Page Inheritence and Visual Studio

 
 
Justin Beckwith
Guest
Posts: n/a
 
      18th Aug 2004
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?
 
Reply With Quote
 
 
 
 
Greg Burns
Guest
Posts: n/a
 
      18th Aug 2004
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.NoCache)

End Sub
End Class

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

Greg

"Justin Beckwith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?



 
Reply With Quote
 
Justin Beckwith
Guest
Posts: n/a
 
      31st Aug 2004
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:<(E-Mail Removed)>...
> 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.NoCache)
>
> End Sub
> End Class
>
> PS: In the future I would post to microsoft.public.dotnet.aspnet group.
>
> Greg
>
> "Justin Beckwith" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling browser back button for GridView Paging and Sorting in Ajax1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008) anil reddy Microsoft C# .NET 0 11th Feb 2009 04:22 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft Dot NET 4 17th May 2007 07:56 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft Dot NET Framework 1 14th May 2007 08:05 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft C# .NET 0 14th May 2007 07:45 PM
HELP: Visual Studio + Dreamweaver, Page Inheritence + Templates Mark Microsoft ASP .NET 1 28th Mar 2005 02:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 AM.