|
发表于 2020-6-28 18:00:01
|
显示全部楼层
Sorry,下班回家晚了点,测试通过:
前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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 language="javascript">
<!--
var a = new Array();
function myClick(e)
{
for(var h=0;h<document.all.length;h++)
{
if(document.all(h).tagName == "INPUT" && document.all(h).type == "radio")
{
if(document.all(h).id == e.id)
{
if(a[h] == 1)
e.checked = false;
else
e.checked = true;
}
}
}
for(var i=0;i<document.all.length;i++)
{
if(document.all(i).tagName == "INPUT" && document.all(i).type == "radio")
{
if(document.all(i).id == e.id)
{
a[i] = 1;
}
else
{
a[i] = 0;
}
}
}
}
//-->
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
后台:
//......
protected void Page_Load(object sender, EventArgs e)
{
for(int i = 0; i < this.RadioButtonList1.Items.Count; i++)
{
this.RadioButtonList1.Items[i].Attributes.Add("onclick", "myClick(this);");
}
} |
|