Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I want to style the radio button list.And i found this thing : http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/[^]

And this is what i have done :
XML
<div>
  <div class="checkbox" id="Cooking">
    <asp:CheckBoxList ID="CheckBoxListAnswer" runat="server">
    </asp:CheckBoxList>
  </div>
</div>

And the generated html runtime is this :
XML
<div>
  <div class="checkbox" id="Cooking">
    <table id="ctl00_ContentPlaceBody_CheckBoxListAnswer" border="0">
      <tr>
        <td>
          <input id="ctl00_ContentPlaceBody_CheckBoxListAnswer_0" type="checkbox" name="ctl00$ContentPlaceBody$CheckBoxListAnswer$0" />
          <label for="ctl00_ContentPlaceBody_CheckBoxListAnswer_0">Good</label>
        </td>
      </tr>
      <tr>
        <td>
          <input id="ctl00_ContentPlaceBody_CheckBoxListAnswer_1" type="checkbox" name="ctl00$ContentPlaceBody$CheckBoxListAnswer$1" />
          <label for="ctl00_ContentPlaceBody_CheckBoxListAnswer_1">Bad</label>
        </td>
      </tr>
      <tr>
        <td>
          <input id="ctl00_ContentPlaceBody_CheckBoxListAnswer_2" type="checkbox" name="ctl00$ContentPlaceBody$CheckBoxListAnswer$2" />
          <label for="ctl00_ContentPlaceBody_CheckBoxListAnswer_2">Not bad</label>
        </td>
      </tr>
    </table>
  </div>
</div>


So the first checkbox is getting the style but the others are only displaying text.So i thought that i should wrap every checkbox inside that div.Is that true and if yes how can i do it?
Posted
Updated 4-Sep-11 19:21pm
v4

1 solution

Hello friend....
you have to do this using javascript.. like this...


HTML
<html>
	<head>
		<title></title>
		<style type="text/css">
            .div
            {
                color: #FF0000;
                border-color: #FF0000;  
            }
    </style>
	<script type="text/javascript">
        function add() {
            var container = document.getElementById("test");
            var chekc = document.createElement("input");
            chekc.type = "checkbox";
            chekc.id = "c1";
            chekc.value = "234";
            var lable = document.createElement("label");
            lable.htmlFor = "c1";
            lable.appendChild(document.createTextNode('label'));
            container.appendChild(chekc);
            container.appendChild(lable);
        }
    </script>
	</head>
	<body>
		<form>
		<input type="button" value="Add Check Box" id="btn" onclick="add();" />
			<div id="test" class="div">
			</div>
		</form>
	</body>
</html>


Like this it is for only html but you can do it for asp.net check box also this is only for hint....
This will work for you...!!!!!
 
Share this answer
 
v2

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