This is a migrated thread and some comments may be shown as answers.

[Solved] Make a Checkbox into a Boolean

0 Answers 15 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 1
John asked on 27 Jan 2012, 07:13 PM
I found a easy way to make a checkbox in my MVC View/Controller into a boolean and it will return either True or False.

View:

This defaults to UnChecked

<%

= Html.CheckBox("chkNoFearSaveData", Model.CheckBox == false ? false : true )%>

This defaults to Checked

 

<%

= Html.CheckBox("chkNoFearSaveData", Model.CheckBox == false ? true : false )%>

Controller:

if ( (bool)model.CheckBox )

 

Tags
ComboBox
Asked by
John
Top achievements
Rank 1
Share this question
or