Reputation: 547
Ok, here we go..
I have a control, which in the assembly.. lets call it "ControlAssembly".
There are a load of controls in this, under the namespace ControlAssembly.Controls.
So, I want to use this in my website, by adding the
<add tagPrefix="ARC" namespace="ControlAssembly.Controls" assembly="ControlAssembly" />
line, as per usual.
However, I would like to override one of the controls in here in the web app.
I have added a load of instances this control to all the pages.
However, in this app, I want to add a language feature, in which it will translate the text value on the OnPreRender method.
I am a lazy lazy man, and I would like to be able to do something like have a new "Control" that inherits ControlAssembly.Controls.Control, and have that go round and effectively replace all the instances of ARC:Control with this Control in this web app.
e.g. Control : ControlAssembly.Controls.Control{ OnPreRender { update text property } }
Having just written this, I guess I could use a render adapter (I suppose) to do this, but I don't really want the stuff that comes with a render adapter attached to my site.
Any suggestions of approaches to this? (I know I could just rename all my controls to TranslatedControl and that would do the job.. but I'd be interested to hear other ideas.
Upvotes: 1
Views: 90
Reputation: 41568
You should be able to add a TagMapping to replace your old controls with your new ones - without having to go back thru and edit all of the pages that use it or having to write any other code.
The idea behind this is that you can tell (via the web.config) your app that you've created a new control, and want to bind the old control's references to the new control.
<pages>
<tagMapping>
<add tagType="ControlAssembly.Controls.MyOldControl"
mappedTagType="MyProjectNamespace.MyNewControl" />
</tagMapping>
</pages>
Upvotes: 2