you have to attach the events with client script.

string s =
string.Format("<script>document.getElementById('{0 }').onfocus=function(){ale
rt('goit');}</script>",MyCheckbox.UniqueId);
RegisterStartupScript("MyCheckBox",s);


-- bruce (sqlwork.com)


"Paul" <qwe@qwe.com> wrote in message
news:0e9101c35134$d4bab160$a501280a@phx.gbl...
> Hi
>
> I need to set up the onfocus event for a checkbox and
> radiobutton server control from the codebehind page. I am
> trying something like:
>
> this.MyCheckbox.Attributes.Add("onfocus", "alert
> ('gotit');");
>
> or
>
> this.MyCheckbox.Attributes["onfocus"] = "alert
> ('gotit');");
>
> but neither work.
>
> As you can see in the generated code the onfocus seems to
> apply to a span tag, not directly to the controls
> themselves:
>
> <span onFocus="alert('gotit');"><label
> for="MyCheckbox">test</label><input id="MyCheckbox"
> type="checkbox" name="MyCheckbox" /></span>
>
> Identical code works for text boxes and list boxes, but
> not for checkboxes or radiobuttons (or groups). I know
> HTML supports the onfocus event for these two controls.
>
> Any ideas?
>
> Thanks, Paul.
>