Checkbox control - won't render attributes correctly

G

Guest

Is there a known bug with the CheckBox control?
I have subclassed the control and I am trying to add an onclick attribute in
the code behind. I've tried putting the Attributes.Add in the Page_Load,
Render, and OnPreRender - but none of them work!
The attributes are rendered in a span that envelopes the input control.
For example, in the OnPreRender I have:
this.Attributes.Add("onblur", "alert('myOnBlur')");

The generated output looks like this:
<span onblur="alert('myOnBlur')"><input id="checkBoxLoc" type="checkbox"
name="checkBoxLoc" /><label for="checkBoxLoc">LocalCheckBox</label></span>

Why is the onblur attribute rendered in the span instead of in the input tag?
If I set the attribute from the Page_Load of the main page, it seems to
work, but this isn't possible in my application. I really need the attributes
to be encapsulated within the control.
I can't use the HtmlCheckBox control because I want server events and
viewState.

I anybody can help, I would really appreciate it.

Thanks
Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top