Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 833715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:33:40+00:00 2026-05-15T04:33:40+00:00

I have some user controls which I want to specify properties and methods for.

  • 0

I have some user controls which I want to specify properties and methods for.

They inherit from a base class, because they all have properties such as “Foo” and “Bar”, and the reason I used a base class is so that I dont have to manually implement all of these properties in each derived class.

However, I want to have a method that is only in the derived classes, not in the base class, as the base class doesn’t know how to “do” the method, so I am thinking of using an interface for this. If i put it in the base class, I have to define some body to return a value (which would be invalid), and always make sure that the overriding method is not calling the base. method

Is the right way to go about this to use both the base class and an interface to expose the method? It seems very round-about, but every way i think about doing it seems wrong…

Let me know if the question is not clear, it’s probably a dumb question but I want to do this right.

EDIT : Thanks to all the people with your excellent abstract suggestions, but this breaks the designer. If abstract was not a selectable option, what would you do?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:33:40+00:00Added an answer on May 15, 2026 at 4:33 am

    Alternatively you could define the method as ‘abstract’ in the base class, which will not require the class to implement it. For example:

    abstract class A
    {
       public abstract void B();
    }
    

    Of course this will force your base class to be abstract as well, but it sounds like this would work just fine for you.

    See Abstract methods on MSDN.

    Update

    Since abstract is not an option for you due to designer issues, you could just define the method as part of your base class, and have it throw a NotImplementedException if it is called directly from the base class:

    void DerivMethod()
    {
        // Must be implemented by derived class
        throw new NotImplementedException();
    }
    

    Otherwise, using an interface would be fine, especially if the above leaves a bad taste in your mouth…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control which uses objects as inner properties (some code is
I have a class UserControlBase that inherits System.Web.UI.UserControl and my user controls inherit UserControlBase
I have a User Control that has some WinForm Controls inside. I want to
For some user controls, I have this binding: AppLanguage={Binding Path=ApplicationLanguage, Source={x:Static Application.Current}} This works
I have got 5 user controls placed in some Control folder, at run time
I'm trying to cache user controls and on some pages i want to cache
I want to create a user control, which can be bound to some data
I have 3 user controls, each one of which will need to pull data
I have multiple user controls loading asynchronously on my page, using pagemethods. Some dropdownlists
I have a simple user control, which is essentially just an AutoCompleteBox with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.