网络编程 
首页 > 网络编程 > 浏览文章

asp.net使用jQuery获取RadioButtonList成员选中内容和值示例

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/UploadFiles/2021-04-02/jquery-1.8.2.min.js">    <link href="Base.css" rel="stylesheet" type="text/css" />
    <style type="text/css">

    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=rblHobbies.ClientID%> input[type=radio]").bind("change", function () {
                if ($(this).val() != "") {
                     $("#message").text("Text:" + $(this).next().text() + "  Value:"+$(this).val());
                }

            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="margin: 100px auto; width: 400px; height: 200px;">
        <fieldset style="width: 400px; height: 150px">
            <p>
                请选择爱好</p>
            <asp:RadioButtonList ID="rblHobbies"  runat="server" >

                <asp:ListItem Value="1">音乐</asp:ListItem>
                <asp:ListItem Value="2">篮球</asp:ListItem>
                <asp:ListItem Value="3">美剧</asp:ListItem>
                <asp:ListItem Value="4">电影</asp:ListItem>

            </asp:RadioButtonList  >
        </fieldset>
        <br />
        <div id="message" style="color:blue;"></div>
    </div>
    </form>
</body>
</html>

上一篇:解决ASP.NET回传后div滚动条位置复位的问题(利用隐藏控件原理)
下一篇:ASP.NET JSON字符串与实体类的互转换示例代码
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网