• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 652
  • Last Modified:

radio input "name" property when runat server

hi

i have the following html

<label id="labelForYes" for="radioYes">Yes</label>
            <input id="radioYes" type="radio" name="radioGroup"
                runat="server" value="1" />
            <label id="labelforNo" for="radioNo"> No</label>
            <input id="radioNo" type="radio" name="radioGroup"
                runat="server" value="0" />

-------------------------------------

then i want to capture the click event when any radios in that group are clicked.
then get the value of the one radio that was selected...
so i thought i would use this code

  $(document).ready(function() {
        $("#radioGroup input").click(function(){            
               //get the value of the radio that has been selected..
            });

however, this doesnt work as "radioGroup" is getting renamed by asp.net.
because i need it to be runat server.

can anyone tell me how to access the "real/client" value of name

thanks

0
MrKevorkian
Asked:
MrKevorkian
  • 2
  • 2
2 Solutions
 
devlab2012Commented:
Change the code to:

<label id="labelForYes" for="radioYes">Yes</label>
            <input id="radioYes" type="radio" name="radioGroup" onclick="processRadio(1);"
                runat="server" value="1" />
            <label id="labelforNo" for="radioNo"> No</label>
            <input id="radioNo" type="radio" name="radioGroup" onclick="processRadio(0);"
                runat="server" value="0" />
0
 
devlab2012Commented:
Please refer to my prev comment. Now you can create a function processRadio as:

function processRadio(radioValue)
{
    if (radioValue == 1)
    {
            //code for YES
    }
    else
    {
             //code for NO
    }
}
0
 
MrKevorkianAuthor Commented:
thanks, that would be a good solution.

i discovered i can do this if i turn my inputs into an asp:radiobuttonlist.

        $('#<%= radioButtonList.ClientID %>').click(function() {
0
 
MrKevorkianAuthor Commented:
i found the answer to this myself, although i was given another good option
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now