473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Abstract Base Page / UserControl

Our current solution has a number of ASP.NET pages with very similar functionality. We would like to move the common functions into a base class that inherits from System.Web.UI.Page, and then force the child classes to override certain functions of that class.

The best way to do this is to define the base class as "MustInherit" and put "MustOverride" on the functions that must be overridden.

However, when we do this, whenever we attempt to open the aspx that inherits from the base class, we recieve the error:

"The file could not be opened in the Web Form designer. Please correct the following error and try again:

Type Abstract

Make sure all the classes used in the page are built or referenced in the project. Click Help for more information."

We have noticed similar behaviour when attempting to inherit a UserControl from an abstract class.

Two questions:

1) Is there any way of having a code-behind class inherit from an abstract (mustinherit) class without seeing the above behaviour in the designer?

2) Will the above behaviour impact the solution at all? We are still able to compile, the only effect we have noticed is that we cannot open the web form in the .NET designer.

Example Code:

PARENT CLASS:
Public MustInherit Class ParentClass
Inherits System.Web.UI.Page

Protected MustOverride Function GetMessageFromChild()

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.Write(Me.GetMessageFromChild)
End Sub
End Class
CHILD CLASS:
Public Class ChildClass
Inherits ParentClass

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Protected Overrides Function GetMessageFromChild() As Object
Return "Here is a message from a child page"
End Function
End Class

Web Form:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ChildClass.aspx.vb" Inherits="WebApplication1.ChildClass"%>
<html>
<body>
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>

Nov 17 '05 #1
1 3684
Hi,

1) Is there any way of having a code-behind class inherit from an
abstract (mustinherit) class without seeing the above behaviour in the
designer? - NO

you can look at Felix Wu [MS] replay :
http://www.developersdex.com/asp/mes...ezFVyhlwCHA%2E
2532%40TK2MSFTNGP10%3E
Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Tee | last post by:
Hi, I have a base usercontrol with a method (blank method, no code), I have another few usercontrols that will inherit this base usercontrol, but I want to force all the usercontrol that...
3
by: Jeff | last post by:
I have an abstract class which uses System.Windows.Forms.UserControl as it's base class. It has some custom drawing methods and it also handles a few common events like Paint, PaintBackGround,...
6
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.