Click here to Skip to main content
15,895,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Hi,
I want to get the value of a selected radiobutton from c# using a pagemethod but It is not working...
Html and JQuery code:
 <script type="text/javascript" src="../javascripts/jquery-1.8.js"></script>
    <script type="text/javascript">
        function scoreQuiz(form) {
            $("Save").click("live", function (e) {
                e.preventDefault();
                if (Page_ClientValidate()) {
                    $.checkSessionExists(function (event, data) {
                        if (data.sessionExists) {
                            PageMethods.Save(($('#<%=rbYesOne.ClientID%>').is(":checked"),
                                function(){
                                    alert("Selected");
                                });
                        else
                            window.location.href = urlpath + "Login.aspx?returnurl=" + encodeURI("MyProduct.aspx");
                    }
                });
            }
        }
    </script>

XML
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:RadioButton ID="rbYesOne" value="1" runat="server" GroupName="Question1" /><br />
    <asp:RadioButton ID="rbNoOne" value="0" runat="server" GroupName="Question1" /><br />
    <asp:Button Text="Save" runat="server" />
   </div>
    </form>
</body>
</html

>
SQL
and code behind file with c# code:

 [WebMethod(EnableSession = true)]//
    public static string Save(bool rdoYesTest)
    {
        HttpContext.Current.Session["rbYesOne"] = rdoYesTest;
        return HttpContext.Current.Session["rbYesOne"].ToString();
    }

Please can someone help fixing this and tell me what the problem is
Posted

1 solution

Try this, it will allow for wildcards in the prefix of the id name such as CT100
$('[id*="rbYesOne"]').is(':checked')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900