/ Published in: HTML
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<%@ 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"> <script type="text/javascript"> var selectedBox = 0; var multiBox = false; var lastChecked = null; $(document).ready( function() { $(".multiplus input:checkbox").click( function() { if (!multiBox) { if ($(this).attr("checked")) { $(lastChecked).attr("checked", false).parent().css({ "background-color": "#FFF", "font-weight": "normal" }); lastChecked = this; } } if ($(this).attr("checked")) { $(this).parent().css({ "background-color": "#FFC", "font-weight": "bold" }); selectedBox++; } else { $(this).parent().css({ "background-color": "#FFF", "font-weight": "normal" }); selectedBox--; } } ); } ); </script> </head> <body> <form id="form1" runat="server"> <div style="width:200px;height:300px;border:1px solid #999;overflow:scroll;"> <asp:CheckBoxList ID="CheckBoxList1" runat="server" DataTextField="Title" DataValueField="RowID" DataSourceID="SqlDataSource1" CssClass="multiplus"> </asp:CheckBoxList> </div> </form> </body> </html>