简体   繁体   中英

CheckBox and RadioButton Control Adapter

I wrote a control adapter a while ago for a CheckBoxList to change the markup, all good.
I then wrote an adapter for a CheckBox, again all good.
I then noticed however that the RadioButton's on the site were using the render method in my Checkbox control adapter.

With RadioButton's being inherited from CheckBox's they are always going to get caught by my CheckBox control adpater. Is there any way I can stop this as I do not want to override the rendering for my radio buttons as it means changing a lot of other code through our CMS.

Alternatively can I escape the Render method in my control adapter if the object is a radiobutton?
I initially thought I could use base.Render(), however obviously it's going the wrong way (they all inherit from WebControl/Control) and I would essentinally need a "parent.Render()".

Any ideas? or am I forced to replicate the radio button rendering in a new control adapter?

My browser file is as follows if it helps...

<adapter controlType="System.Web.UI.WebControls.DropDownList" adapterType="Skylight.Core.Utility.ControlAdapters.DropDownListAdapter" />
<adapter controlType="System.Web.UI.WebControls.Image" adapterType="Skylight.Core.Utility.ControlAdapters.ImageAdapter" />
<adapter controlType="System.Web.UI.WebControls.CheckBoxList" adapterType="Skylight.Core.Utility.ControlAdapters.CheckBoxListAdapter" />
<adapter controlType="System.Web.UI.WebControls.CheckBox" adapterType="Skylight.Core.Utility.ControlAdapters.CheckBoxAdapter" />

Thanks a lot.
Dan

I have found a solution to this myself, taken a couple of hours, but...

If you add a control adapter for RadioButton and use an adapterType of HideDisabledControlAdapter above the checkbox adapter, it will render the radiobutton as normal.

<adapter controlType="System.Web.UI.WebControls.RadioButton" adapterType="System.Web.UI.WebControls.Adapters.HideDisabledControlAdapter" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM