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 4567154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:53:25+00:00 2026-05-21T18:53:25+00:00

I need to inject a new behaviour for every dropDownList control of my web

  • 0

I need to inject a new behaviour for every dropDownList control of my web app (asp.net/C#).
Each time a new value is selected in the dropdown a web method (using Ajax/JSON) is invoked.

Since I have “normal” controls of type DropDownList and custom controls using DropDownList within them, I planned to create a class inheriting from DropDownList class with the new behaviour and then switch all the currrent DropDownList instances to this one.

In this way all my normal and custom drop downs would automatically get the new feature.
However the custom control has already an impementation for the “onselectedindexchanged” event, where some other functions are implemented.
Since I would use the same event for the new (parent) class, it would be overwritten in the custom control.

Of course I can write in the custom control the same code as in the parent, but is there a way to avoid duplicate code?

Thanks,
Luca

  • 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-21T18:53:26+00:00Added an answer on May 21, 2026 at 6:53 pm

    Of course I can write in the custom
    control the same code as in the
    parent, but is there a way to avoid
    duplicate code?

    C#:

    public void doSomething() {
        base.doSomething(); //parent class
        //My stuff here
    }
    

    Java

    public void doSomething() {
        parent.doSomething(); //parent class
        //My stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have two branches, Parent(Main) and Child(Release). I need to inject a new
I need to inject generic repositories (IRepository) into my classes' constructors but I dont
I'm new to Servlet containers and have created a web application using Tomcat 6.0.26.
I have 2 implementations of an interface where I need to inject the first
While inside a not trasient conversation, I need to start a new conversation for
Using Guice, if I have @Inject @Named(light) Color light; I can use bind(Color.class).annotatedWith(Names.named(light)) .toInstance(new
I am working with ASP.Net MVC3 , the easier way to use the client
So like most new .NET developers you start of passing DataSets everywhere and although
I'm new to JSF and I'm wondering if it's possible to inject different subclasses
I working on asp.net mvc3 project. I am using autofac for DI. I have

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.