Last post Mar 19, 2008 06:12 PM by imagemaker
Mar 19, 2008 12:46 PM|ronchese|LINK
I'm to add some custom attributes to a custom checkbox control, but I'm getting stuck because the base CheckBox control is behaving weird (I guess).
I tested several ways to add the attribute, but for this post I'll say that RenderBeginTag() is not being executed. See:
Note I added a breakpoint to check if it is working. It is not! When I run the page hosting the control, the process never breaks in the breakpoint I defined.
NOTE 1: To test if I'm not crazy, I added the breakpoints to another overrides, and it works well. The only overrides I noticed are not working are RenderBeginTag() and RenderEndTag().
NOTE 2: This issue happen only with CheckBox. Buttons, for example, are working fine in my tests.
NOTE 3: AddAttributesToRender() also don't work for the CheckBox, because it is producing a
span tag out of the control. See:
<input id="CheckBox2" type="checkbox" name="CheckBox2" />
Do you know how can I add my custom attributes to my custom CheckBox, like the sample below?
<input id="CheckBox2" type="checkbox" name="CheckBox2" MyAttribute="someValue" />
I hope I dont need to full override the RenderControl(), hehe. I want to enjoy all the working features of CheckBox control.
Mar 19, 2008 06:12 PM|imagemaker|LINK
Because the CheckBox control itself overrides the Render method, RenderBeginTag, RenderContents, RenderEndTag will never be called. You would have to override Render but I seem to recall that it is declared with Friend scope. I'd suggest you take a look
at the Render code using Lutz Roeder's .Net Reflector.