3

Is there any way to have a toggle button in asp.net MVC instead of CheckboxFor?

I am using twitter bootstrap but I can't find any classes which has that effect.

Any help would be great.

Thanks

2 Answers 2

5

Try: https://bttstrp.github.io/bootstrap-switch/

<input type="checkbox" name="my-checkbox" checked><input type="checkbox" name="my-checkbox" checked>

$("[name='my-checkbox']").bootstrapSwitch();
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks For your reply. I did what you suggested and toggle buttons are working. but if I use mvc html helper like @Html.CheckBoxFor(m => m.DoDetection), the toggle button are appearing twice. Did you ever encountered this problem?
ok, got it working with a slight change: $(document).ready(function () { var checkBox = $("[name='DoReplayDetection']").not('[type="hidden"]'); checkBox.bootstrapSwitch('onColor', 'danger'); });
above given link is broken
1

Is the Single Toggle button not right for you? http://getbootstrap.com/javascript/#buttons

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.