User Control Inheritance Problem

T

tjmii

I'm trying to use several web user controls on a page that share some common
functionality. So, I want the user controls to inherit from a base class.
I started off making this simple base class

Public Class BaseClass : Inherits System.Web.UI.UserControl
Public Property TableWidth as Integer
Get
Return baseTable.Width
End Get
Set (ByVal Value As Integer)
baseTable.Width = Value
End Set
End Property

Protected WithEvents baseTable As System.Web.UI.WebControls.Table
End Class

I have the code behind for a child class called ChildControl that looks like
this

Public MustInherit Class ChildControl : Inherits BaseClass
' Standard wizard generated code here...
End Class

This code compiles and runs without any problems, but I'm unable to open my
user control in the form designer anymore. I get the following error:

"The file failed to load in the Web Form Designer. Please correct the
following error, then load it again: Property accessor TableWidth on object
ChildControl threw the following exception: 'Object reference not set to an
instance of an object.'"

Is this a known bug with the form designer? Is there any work around so I
can have my control inherit from a base class AND be able to edit it in the
form designer?

Tom
 
T

tjmii

I did a search on google before posting, but did not find anything that was
useful. I found one post about making the base class abstract, but that did
not make any difference. Could you provide a link, or let me know what
needs to be done to resolve this problem? Thanks.

Tom
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top