Solved

<asp:RadioButtonList get value in the code behind

Posted on 2010-08-16
6
607 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

730 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