Web UserControl and Visual Inheritance

B

Ben Fidge

Hi

I have a situation where it would be very advantageous to
be able to derive a new web UserControl from an existing
one, making the bases server controls available to the
derived class (and therefore, visible to the user).

I know how to derive from a base class so that common
code is available to the derived class, but I need to UI
elements to be visible in the new usercontrol too.

Any ideas?

Ben
 
O

Oleg Ogurok

I believe that's impossible.
When you execute a page (view it in browser), your ASPX or ASCX content is
transformed into a classon the fly. This class is always inherited from the
codebehind (.cs).
As far as I know, you can't derive from ASPX or ASCX. Therefore you can't
create a derived user control that would include the visual parts of the
base one.
Your only choice is to add your controls programmatically in the codebehind
of the base class, and then inherit.

-Oleg.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top