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
Solved

<asp:RadioButtonList get value in the code behind

Posted on 2010-08-16
6
606 Views
Last Modified: 2012-05-10
hi guys, as I can get and value of what the user has selectionof? to process it in the code behind
0
Comment
Question by:enrique_aeo
  • 4
6 Comments
 
LVL 5

Assisted Solution

by:JayFromPep
JayFromPep earned 100 total points
ID: 33446247
You will have to provide us with more information for us to help you.

I think you are trying to get at radiobuttonlist.selecteditem.value
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33446277
In code behind you have :

rblSeguimientoCritica.SelectedValue

and

rblInovacionFundada.SelectedValue
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33446397
If you want to get at client side, use :


function getSelectedValue(rbListName) {
        var inputs = document.forms[0].getElementsByTagName("input");
        for (var i = 0; i < inputs.length; i++) {
            if ( inputs[i].name.indexOf(rbListName)>=0 && inputs[i].type == "radio" && inputs[i].checked) return inputs[i].value;
        }
    }

Open in new window

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 82

Expert Comment

by:leakim971
ID: 33446405
example of using :


<table>
<tr class="TableItemAltFirst">
                <td class="style4">Seguimiento o crítica fundada en los precedentes. Universalidad.</td>
                <td>
                    <asp:RadioButtonList ID="rblSeguimientoCritica" runat="server" RepeatDirection="Horizontal" >
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                    </asp:RadioButtonList>
                </td>            
            </tr>
            <tr class="TableItemAltSecond">
                <td class="style4">Innovación fundada en la interpretación creativa, posible y razonable del derecho, o del ordenamiento jurídico.</td>
                <td>
                    <asp:RadioButtonList ID="rblInovacionFundada" runat="server" RepeatDirection="Horizontal" >
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                    </asp:RadioButtonList>
                </td>          
            </tr>
            </table>
<script language="javascript" type="text/javascript">
    function checkRadioIsSet() {
        var inputs = document.forms[0].getElementsByTagName("input");
        var allForEachGroupIsChecked = true;
        for (var i = 0; i < inputs.length; i++) {
            if (inputs[i].type == "radio") {
                var oneIsChecked = false;
                var lastName = inputs[i].name;
                while (lastName == inputs[i].name) {
                    if (inputs[i].checked) oneIsChecked = true;
                    i++;
                }
                i--;
                allForEachGroupIsChecked = allForEachGroupIsChecked && oneIsChecked;
            }
        }
        if (allForEachGroupIsChecked) {
            return allForEachGroupIsChecked;
        }
        else {
            alert("choose an answer for all questions!");
            return allForEachGroupIsChecked;
        }
    }
    function getSelectedValue(rbListName) {
        var inputs = document.forms[0].getElementsByTagName("input");
        for (var i = 0; i < inputs.length; i++) {
            if ( inputs[i].name.indexOf(rbListName)>=0 && inputs[i].type == "radio" && inputs[i].checked) return inputs[i].value;
        }
    }
</script>
<asp:Button ID="btnSave" runat="server" Text="Grabar Informacion" OnClientClick="return checkRadioIsSet();" />
<asp:Button ID="Button1" runat="server" Text="get selected value for Seguimiento Critica" OnClientClick="alert(getSelectedValue('rblSeguimientoCritica'));" />
<asp:Button ID="Button2" runat="server" Text="get selected value for Inovacion Fundada" OnClientClick="alert(getSelectedValue('rblInovacionFundada'));" />

Open in new window

0
 

Author Comment

by:enrique_aeo
ID: 33446703
Please leakim971,
please, could you complete the example in the code behind?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 150 total points
ID: 33446737
in code behind why don't you want to use :

rblSeguimientoCritica.SelectedValue
and
rblInovacionFundada.SelectedValue
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

861 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