Solved

radio input "name" property when runat server

Posted on 2011-02-15
4
624 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
i found the answer to this myself, although i was given another good option
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now