I have attempted the following methods, and I believe the question is pretty clear.
Attempted Solution Using CSS: (Unfortunately, this approach did not work as expected and I had to resort to using a jsfiddle)
.star + label{
background:url('image1.png') no-repeat;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
.star:checked + label{
background:url('image2.png') no-repeat;
height: 16px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
jQuery Approach Used: (This method showed some progress, but it was only partially successful)
$('.star').replaceWith("<img src='image1.png' />");
$('.star').click(function () {
var $checkbox = $(this).prev(".star");
$checkbox.prop('checked', !$checkbox.prop('checked'));
if ($checkbox.prop("checked")) {
$image.attr("src", "image2.png");
} else {
$image.attr("src", "image1.png");
}
})
You can view the JSFIDDLE for a better understanding: fiddle
Below is an excerpt of the code on the ASPX page:
<span>
<asp:CheckBox ID="star1" CssClass="star" runat="server" />
<asp:CheckBox ID="star2" CssClass="star" runat="server" />
<asp:CheckBox ID="star3" CssClass="star" runat="server" />
<asp:CheckBox ID="star4" CssClass="star" runat="server" />
<asp:CheckBox ID="star5" CssClass="star" runat="server" />
</span>
Any insights on what might be going wrong? I've explored various solutions (including those from similar questions here), but they do not address the specific scenario involving asp.NET.