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 ;-)