• ASP.NET jQuery 随笔 显示RadioButtonList成员选中的内容和值


    通过jQuery来获取RadioButtonList成员内容。

    <%@ 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="jquery-1.8.2.min.js" type="text/javascript"></script>
        <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;  400px; height: 200px;">
            <fieldset style=" 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>
  • 相关阅读:
    为什么用strlcpy取代strncpy
    linux系统调用和库函数调用的区别
    VC、PE和天使投资是什么意思?有什么区别?
    AWS使用心得:当初我曾错过的那些宝贵经验
    bzoj 2208: [Jsoi2010]连通数
    android学习笔记(5)Activity生命周期学习
    Nginx 进程间通信
    手写一个节点大小平衡树(SBT)模板,留着用
    JavaFX学习之道:JavaFX之TableView
    Docker 命令行和后台參数
  • 原文地址:https://www.cnblogs.com/jlcoder/p/3471183.html
Copyright © 2020-2023  润新知