Solved

radio input "name" property when runat server

Posted on 2011-02-15
4
627 Views
Last Modified: 2012-06-27
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
Comment
Question by:MrKevorkian
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:devlab2012
ID: 34897456
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
 
LVL 13

Assisted Solution

by:devlab2012
devlab2012 earned 150 total points
ID: 34897492
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
 
LVL 1

Accepted Solution

by:
MrKevorkian earned 0 total points
ID: 34897804
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
 
LVL 1

Author Closing Comment

by:MrKevorkian
ID: 34936408
i found the answer to this myself, although i was given another good option
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question