Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

radio input "name" property when runat server

Posted on 2011-02-15
4
Medium Priority
?
641 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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