在.net中提供了Radiobuttonlist来实现单选的,但是我一直喜欢用CheckBoxList
<asp:CheckBoxList ID="CheckBoxList1" BorderWidth="1" runat="server" Re
PEatLayout="Flow">
<asp:List
ITem onclick="CheckBoxList_Click(this)" Value="Item1">Item1</asp:ListItem>
<asp:ListItem onclick="CheckBoxList_Click(this)" Value="Item2">Item2</asp:ListItem>
<asp:ListItem onclick="CheckBoxList_Click(this)" Value="Item3">Item3</asp:ListItem>
<asp:ListItem onclick="CheckBoxList_Click(this)" Value="Item4">Item4</asp:ListItem>
<asp:ListItem onclick="CheckBoxList_Click(this)" Value="Item5">Item5</asp:ListItem>
</asp:CheckBoxList>
function CheckBoxList_Click(sender)
{
VAR cont
ainer = sender.parentNode;
if(container.tagN
ame.toUpperCase()
== "TD") { //
服务器控件设置呈现为 table 布局(默认设置),否则使用流布局
container = container.parentNode.parentNode; // 层次: <table><tr><td><input />
}
var chkList = container.
getelementsbytagname("input");
var sender
state = sender.checked;
for(var i=0; i<chkList.length;
i++) {
chkList[i].checked = false;
}
sender.checked = senderState;
}