Master pages, radio buttons and JavaScript, oh my!

Discussion in 'ASP .Net Web Controls' started by CtrlAltDel, Oct 13, 2006.

  1. CtrlAltDel

    CtrlAltDel Guest

    Here's a question for you - how do you reference the name of a radio
    button group in JavaScript, when .NET insists on mangling the name?

    If you have controls such as:

    <asp:radiobutton id="button1" runat="server" groupname="mygroup" />
    <asp:radiobutton id="button2" runat="server" groupname="mygroup" />

    then the output ends up being something like this

    <input id="ctl00_contentholder_parent_button1"
    name="ctl00$contentholder$parent$mygroup" />
    <input id="ctl00_contentholder_parent_button2"
    name="ctl00$contentholder$parent$mygroup" />

    (this example comes from .NET 2, hence the contentholder text)

    Now the element can be referenced using Control.ClientID, and that
    value written to your JavaScript. However, there isn't a readily
    accessible equivalent for GroupName. VS2005 gives a tantalising peek
    when debugging, by showing a private property UniqueGroupName, which
    contains the desired value of ctl00$contentholder$parent$mygroup, but
    as it's private, it's not readily accessible.

    Any thoughts, other than *ug* hard coding the reference and praying
    that no-one renames something?
     
    CtrlAltDel, Oct 13, 2006
    #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. Doug McCann
    Replies:
    1
    Views:
    1,062
    William Brogden
    Aug 5, 2004
  2. Replies:
    1
    Views:
    3,239
    PeterKellner
    May 16, 2006
  3. Scott D Johnson
    Replies:
    1
    Views:
    1,081
    Scott D Johnson
    Sep 27, 2006
  4. Dr. Leff
    Replies:
    3
    Views:
    301
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    232
    David Mark
    Oct 15, 2007
Loading...

Share This Page