UserControl, Inheritance and the VS Designer

T

Travis Bolton

I have a problem that seems like it should be simple (or not really a
problem in the first place), that has become quite frustrating.

I have a page that has several user controls on it. I am retrieving an
object on the Web Form that each User Control will need. So instead of
manually creating the exact same public property in each user control, I
want to create a base user control that inherits from
System.Web.UI.UserControl which will handle the commong properties and then
derive each of my User Controls from that base class.

I have:

Public Class UserControlBase
Inherits System.Web.UI.UserContrl

Protected mSomeVal

Public Property SomeVal() as SomeType
Get
return mSomeVal
End Get
Set (Value as SomeType)
mSomeVal = Value
End Set
End Property

End Class

Public Class MyUserControl
Inherits UserControlBase

'All the stuff to show the page, including Page_Load, etc.
End Class

When I try to view the .ascx file in Visual Studio to design the actual user
control, I get an error message that says:

"The file could not be loaded into the Web Forms designer. Please correct
the following error and the try loading it again:

Type Abstract

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

The Help button on the error is, of course, no help :)

Any help would be greatly appreciated. I've already blown several hours
trying to figure this out. I know I could do it with an interface, but then
I'd still have to code the properties in each user control so that wouldn't
get me too much.

Thanks,
Travis
 
J

John Saunders

I don't believe that anyone has gotten this to work. Just another limitation
of User Controls.
 
T

Travis Bolton

Actually, after I sent the original message, it started working.

I decided for now I would just inherit from UserControl when I needed to
mess with the visual design, and change it back when I was done in the
designer.

So I did that, and then changed back to inherit from my base class and ran
my project. Since then, I have been able to edit my user controls in the
visual editor, even while inheriting from my base class. I don't know if
it's because I ran the project, maybe it "figured" something out. Or if it
was because I editied it while inheriting from UserControl, but I can now
edit all my usercontrols that inherit from my base class in the visual
editor.

No telling what it will be like tomorrow, though...
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top