asp. net USES jQuery to get examples of RadioButtonList member selections and values
- 2020-09-28 08:51:17
- OfStack
<%@ 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; width: 400px; height: 200px;">
<fieldset style="width: 400px; height: 150px">
<p>
Please choose a hobby </p>
<asp:RadioButtonList ID="rblHobbies" runat="server" >
<asp:ListItem Value="1"> music </asp:ListItem>
<asp:ListItem Value="2"> basketball </asp:ListItem>
<asp:ListItem Value="3"> The TV show </asp:ListItem>
<asp:ListItem Value="4"> The movie </asp:ListItem>
</asp:RadioButtonList >
</fieldset>
<br />
<div id="message" style="color:blue;"></div>
</div>
</form>
</body>
</html>