In a base class, the pre-render adds a Javascript to the page. In my derived class, I want to replace the Javascript with one of my own resource script.
If the script is being added like this in the base class:
this.Page.ClientScript.RegisterClientScriptResource(typeof(GeomappingEditor), "SomeSpace.Resources.Scripts.Geomapping.js");
Then can I do something like this:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
//HOW TO OVERWRITE JAVASCRIPT FILE HERE?
}
The reason why I thought this may be possible is because sometimes Javascript is added onto a page with a key like this:
this.Page.ClientScript.RegisterClientScriptInclude("geomapping", this.ApiScript);
So I know I can add another script in the page with “geomapping” being the key and it will overwrite the previous script. But it does not seem there is a key like this for “RegisterClientScriptResource”. Any ideas on how to achieve this?
In the base class, add a virtual/overridable method to register the script, and in the base class, you override it that method and don’t call the base implementation. That would override it.
ALso,