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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:04:44+00:00 2026-05-17T22:04:44+00:00

I have a hierarchy in my website project as below: [CustomControl1 – folder] –

  • 0

I have a hierarchy in my website project as below:

[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js

I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:

protected void Page_Load(object sender, EventArgs e)
{
    CustomControl1.AddLinks( Page.Header);
    CustomControl2.AddLinks( Page.Header);
    ...
}

where AddLinks method adds HtmlLink controls to Page.Header with href attribute set to coresponding css and/or js file.

I would like to add Interface that would force new controls to have AddLinks method but it is impossible since it is a static method. Because my custom controls inherit from Control class I cannot use abstract class and/or virtual methods either. How can I achieve my goal?

Note:

I know that similar ( about static methods in interfaces) questions was posted on SO before but I didnt found proper solution there. ( or I am too noobish to know that it was a proper solution 😉

  • 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-17T22:04:44+00:00Added an answer on May 17, 2026 at 10:04 pm

    You cant. I can see exactly why you’d like to have a static method on the interface here to implement your pattern, but c# doesnt allow static methods on interfaces, so your at a dead end here.

    Assuming you dont want to just call a method on an instance of your control for some reason, your stuck in either making sure you implement all your static methods, using reflection(smelly) etc.

    Why cant you just use

    
     myCustomControl1Instance.AddLinks(Page.Header);
     myCustomControl2Instance.AddLinks(Page.Header);
    
    

    also, personally, I think the control should be smart enough to add the links if its needs them. Page.ClientScript contains methods for doing this.

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

Sidebar

Related Questions

I have a view hierarchy that has a UIViewController as Files Owner in the
i have the structure of the website all pages in folders --- home [directory]
I need to migrate a website to a new CMS. We do not have
i have a view in which i have table view and when user taps
I have the following hierarchy: Party is a base class, extended by Person and
I have this model: class Category(models.Model): name = models.CharField() description = models.CharField(blank=True) parent =
Assume the following program: var SomeConstructor = function() { }; var instance = new
I analyzed the code I am working on using a Java source code analyzer.
How do I push a view control over a UISPlitViewController? Or How do I

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.