Solved

<asp:RadioButtonList get value in the code behind

Posted on 2010-08-16
6
596 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
Comment Utility
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
Comment Utility
In code behind you have :

rblSeguimientoCritica.SelectedValue

and

rblInovacionFundada.SelectedValue
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Comment Utility
Please leakim971,
please, could you complete the example in the code behind?
0
 
LVL 82

Accepted Solution

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

rblSeguimientoCritica.SelectedValue
and
rblInovacionFundada.SelectedValue
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 …
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now