I am trying to write a simple ControlAdapter below is a very simplified case, but I still can't seem to get it to work. In my simplified case I just want to write something out before my control is rendered.
I defined my control adapter as such:
using System.Web.UI;
using System.Web.UI.WebControls.Adapters;
namespace Test.Web.Common.Controls.ControlAdapters {
public class RadioBtnStyleAdapter : WebControlAdapter {
protected override void BeginRender(HtmlTextWriter writer) {
writer.WriteLine("<!--- CONTROL ADAPTER -->");
writer.WriteLine("<div><b>TEST</b></div");
base.BeginRender(writer);
}
}
}
- I then added an App_Browsers folder under my Test.Web project.
- I then added a default.browser file under App_Browsers
And my default.browsers looks like
<browsers>
<browser id="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.WebControls.RadioButton" adapterType="Test.Web.Common.Controls.ControlAdapters.RadioBtnStyleAdapter"></adapter>
</controlAdapters>
</browser>
</browsers>
It is my understanding that should be enough, and the framework should pick up the the adapter, however it never actually seems to fire.
Any suggestions about what I could be missing?
Update
I am able get it to work if I programmaticaly add the adapter on Page_Init like so
HttpContext.Current.Request.Browser.Adapters["System.Web.UI.WebControls.RadioButton"] = "Test.Web.Common.Controls.ControlAdapters.RadioBtnStyleAdapter";
But nothing I have read show this as a required step, so I am not convinced this is correct.