ASP.NET – Tag Mapping

Tag Mapping is not a new ASP.NET 2.0 feature, but only recently many people discover it.

<system.web>
<pages>
<tagMapping>
<add tagType=”System.Web.UI.WebControls.TextBox”
     mappedTagType=”MyTextBox”/>
tagMapping>
pages>

The use of Tag Mapping allow us to, at parsing time, replace a given control type with other control type. The only constrain is that new control type extends primary control type.

If I use Tag Mapping with Web Controls everything works fine but if, instead, I use Html Controls, like HtmlForm, with tag mapping no mapping is done.

Using Reflector I found no reason for this behavior.