Re: Checkbox and Radiobutton onfocus events

Discussion in 'ASP .Net' started by bruce barker, Jul 23, 2003.

  1. bruce barker

    bruce barker Guest

    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" <> wrote in message
    news:0e9101c35134$d4bab160$...
    > 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.
    >
    bruce barker, Jul 23, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alien2_51
    Replies:
    2
    Views:
    3,904
  2. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    order of events - dynamic checkbox events

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    562
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  3. Nathan Sokalski
    Replies:
    1
    Views:
    429
    Teemu Keiski
    Nov 11, 2007
  4. Paul

    Checkbox and Radiobutton onfocus events

    Paul, Jul 17, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    168
  5. Nathan Sokalski

    RadioButton and CheckBox Controls: Where is the value attribute?

    Nathan Sokalski, Nov 10, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    241
    Teemu Keiski
    Nov 11, 2007
Loading...

Share This Page