Using CheckBoxList to implement a single selection in. Net

Source: Internet
Author: User
Use CheckBoxList to achieve the reason for the single election is that I think CheckBoxList control page display effect to look some, need friends can refer to the next RadioButtonList is provided in. NET to achieve a single selection, but I always like to use CheckBoxList reason I think CheckBoxList control page display effect to look some, hehe     Here is the first CheckBoxList implementation of the control of the Click event Call JS to control the single selected     such as the page below:    code as follows: <asp:checkboxlist id= " CheckBoxList1 "borderwidth=" 1 "runat=" server "repeatlayout=" Flow ">  <asp:listitem 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>      Here is the call of the js    principle is: 1, Get page control collection, loop lookup check     2, set check to False, and then set the incoming control to check the   generationCode is as follows: function Checkboxlist_click (sender)   {  var container = sender.parentnode;  if ( Container.tagName.toUpperCase () = "TD") {//server control settings render as table layout (default setting), otherwise use flow layout   container = Container.parentNode.parentNode; Level: <table><tr><td><input/> }  var chklist = Container.getelementsbytagname (" Input ");  var senderstate = sender.checked;  for (var i=0; i<chklist.length;i++) {  chklist[i].checked = false; }  sender.checked = senderstate; } 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.