.NET Framework 2.0 SP1 – TagMapping Undocumented hotfix

While searching a way to solve the HtmlControls tag mapping problem I found that the new SP1 bring an extra undocumented hotfix.

This undocumented hotfix changes MainTagNameToTypeMapper.GetControlType method so that, for every tag name regardless is kind, a tag type mapping is always performed.

This little change enables us to tag map HtmlControls the same way we map WebControls and UserControls. Here is an example: [more]

 

<system.web> <pages> <tagMapping> <add tagType="System.Web.UI.HtmlControls.HtmlForm, System.Web, Version=2.0.0.0" mappedTagType="tagmapping.controls.Form, tagmapping" /> </tagMapping> </pages> </system.web>

 

This tag mapping problem is also fixed for .NET Framework 3.5.

For those of you who still use .NETFX 2.0 without SP1 the only solution I found available is:

 

<system.web> <pages> <controls> <add tagPrefix="html" namespace="System.Web.UI.HtmlControls" assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </controls> <tagMapping> <add tagType="System.Web.UI.HtmlControls.HtmlForm, System.Web, Version=2.0.0.0" mappedTagType="tagmapping.controls.Form, tagmapping" /> </tagMapping> </pages> </system.web>

 

Then you should replace the <form> tag with an <html:HtmlForm> tag in your pages.

kick it on DotNetKicks.com

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.