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

  • Home
  • SEARCH
  • 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 7604119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:49:42+00:00 2026-05-30T23:49:42+00:00

My situation is that I have a control that is implemented to handle two

  • 0

My situation is that I have a control that is implemented to handle two different types. So in some of the methods I have if(controlType == "Type1")
...
else...
I would like to split this into two different controls with a base class to handle the common operations of both controls. Both controls would have the same markup too so I would like to handle the control events in the base class but the designer seems to screw this up for me. I almost feel like a generic .ascx would be perfect but I don’t know where to start with that.

  • 1 1 Answer
  • 0 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-30T23:49:44+00:00Added an answer on May 30, 2026 at 11:49 pm

    In the past I’ve tried all sorts of things with inheritance and user controls, including one ascx inheriting from another ascx, and decided in retrospect it wasn’t worth the trouble as the maintenance of it tends to be a bit of a headache.

    Having two ascx controls inheriting from a common base class works out ok, but I too found trying to handle the events in the base class gets difficult. In the end I just called methods in the base class from the events. You have to handle the events in both controls, but at least people will can follow the code 2 years from now.

    Generic ascx would be awesome and is possible:

    • C# generics usercontrol
    • Is it Possible to Make a Generic Control in .Net 3.5?

    BUT although this is a clever workaround, as the EDI doesn’t directly support it I suspect it will end up adding to the maintenance problems.

    I know it’s probably not the answer you’re looking for, but having ugly if(controlType == "Type1") code, although it feels inelegant, may end up being the easiest to maintain, just because Visual Studio doesn’t inherently support inheritance for user controls.

    Good luck, and if you find an elegant solution, please let me know!

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

Sidebar

Related Questions

NOTE: EDITED The real-world situation is a series of events that each have two
I am trying to handle flow control situation on producer end. I have a
I have a number Processor classes that will do two very different things, but
I have implemented a user control that I reuse on several pages. However, I
I’m in the situation that I have to design and implement a rather big
I have that situation: I have models Item, Region and Country. class Item(models.Model): name
All, I am new to Windows 7 Phone. My situation is that I have
First, the code: tab_textArea_file.addTab(docLabel, null, scrollPane_textArea, null); So the situation is that I have
I have a situation that has been partially covered by other answers at SO,
I have a situation that requires redirecting users who are already logged in away

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.