I am adding a new control to a project that has some ASP.Net controls. Each control essentially comprises of a .Net class (inheriting ScriptControl) and a javascript file. Each of the js files are added to the assembly as a WebResource
[assembly: WebResource("Assembly.Namespace.WidgetControl.js", "text/javascript")]
[assembly: WebResource("Assembly.Namespace.CogControl.js", "text/javascript")]
I'm wanting to inherit from a "class" in another javascript resource from one of the other controls because otherwise I would need to copy/paste code some of the function code from the js class I want to inherit from which is ugly, ugly, ugly for maintenance. I'm not a fan of duplicated efforts.
Now, what I am after is WebResource loading order. Let's say, for demonstrative purposes, I would like to inherit from the class in WidgetControl.js
and extend it with ThingaMahBobControl.js
. Does adding the WebResource assembly reference for ThingaMahBob after Widget guarantee load order?
I can't inherit from something that has not yet been loaded, so this is vital. Since the control is inheriting the abstract ScriptControl, it has to implement GetScriptReferences()
so would returning the enumerable collection of references in the desired order work? i.e.:
protected override IEnumerable<ScriptReference> GetScriptReferences()
{
List<ScriptReference> refs = new List<ScriptReference>();
refs.Add(new ScriptReference("Assembly.Namespace.WidgetControl.js", this.GetType().Assembly.FullName));
refs.Add(new ScriptReference("Assembly.Namespace.ThingaMahBobControl.js", this.GetType().Assembly.FullName));
return refs;
}