Solved

<asp:RadioButtonList get value in the code behind

Posted on 2010-08-16
6
601 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

930 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

14 Experts available now in Live!

Get 1:1 Help Now