Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<td style="border-style: none; ">
                                <div align="center" class="unchkd" id="seatselect">
                                    <asp:CheckBox ID="A3" runat="server" style="content:seatselect"/>
                                    <asp:CheckBox ID="A4" runat="server" AutoPostBack="True"/>
                                    <asp:CheckBox ID="A5" runat="server" AutoPostBack="True"/>
                                    <asp:CheckBox ID="A6" runat="server" AutoPostBack="True"/>






..................................................................................................
dear sir, i want to change background color, but if checkbox is unchecked the background color is red and checkbox is check thene background color is white of this chekcbox...
plz help.....
Posted
Comments
Ankur\m/ 12-Mar-14 8:40am    
Please please please do Google before you ask!

See the following example:
Let say you have 2 checkboxes in the body of the aspx page:
XML
<asp:CheckBox ID="A5" runat="server" AutoPostBack="false"/>
<asp:CheckBox ID="A6" runat="server" AutoPostBack="false"/>

Add the following css and jquery to the head section:
XML
<style type='text/css'>
.checkedColor {
    background-color: red;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
$(function(){
  var $chk = $('input:checkbox');

  // wrap each checkbox with a span tag to act as background
  $chk.wrap('<span />');

  $chk.click(function(){
       $(this).parent().toggleClass('checkedColor');
  });
});
</script>

The background color of the span surrounding the checkbox will toggle between red and non-red whenever its checked status changes.
Enjoy.
 
Share this answer
 
v2
Comments
Rajkumar_007 13-Mar-14 1:21am    
Thank You very much Sir.....Have a good Morning....
Peter Leow 13-Mar-14 2:25am    
You are welcome, have a nice day.
 
Share this answer
 
use css class property of the asp:Checkbox Control
 
Share this answer
 
your Requirement not clear .......
 
Share this answer
 
 
Share this answer
 
Google[^] is banned, I guess.

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900