You dont have to use the HTML helper because as zholinho said, HTML helper create an extra input and that make the css do not work. Just delete your HTML and put a manual input, ypu can set the values as follow:
<div class="checkbox checkbox-primary pull-right">
<input type="checkbox" name="NameOfAttribute" checked="@Model.AttributeBoolean" id="NameOfAttribute" value="@Model.AttributeBoolean.ToString().ToLower()" />
<label for="NameOfAttribute">Label Text</label>
</div>
To get if the element it´s cheked just use:
var chk = $('input[name="NameOfAttribute"]:checked').length > 0
This example was to detect a false or true, if you need the actual values use the val() function.
Hope this could help to everyone with the same problema.
dgarzam (1) - 6 years ago - Reply 1
It doesn't work when i use it in ASP.NET dynamic checkboxes or radiobuttons, is there any solution?
Mahnoor Khan () - 7 years ago - Reply -1
Does it support rtl? When switching to rtl locale, the labels are on the right side of the check box instead of to the left.
Any suggestions?
shal () - 7 years ago - Reply -1
For ASP.NET MVC, see added rules here(https://gist.github.com/jmv....
JMV Trinidad () - 8 years ago - Reply 0
It doesn't work with razor CheckBoxFor, probably because it generates one hidden input between input and label. Does anyone have some quick solution for this?
zholinho () - 9 years ago - Reply 0
I have a same issue. can You help me?
My rozor
<div class="checkbox checkbox-primary">
@Html.CheckBox(itemQ.QuestionID.ToString(), new { value = itemA.AnswerID, @id = @idControl })<label for="@idControl">@Html.DisplayFor(modelItem => itemA.AnswerText)</label>
</div>
Raien () - 9 years ago - Reply 0