@using (Html.BeginForm()) {
@Html.DevExpress().CheckBox(checkBoxSettings => {
checkBoxSettings.Name = "includeHistory";
checkBoxSettings.Text = "Include History";
checkBoxSettings.Properties.ValueChecked = "true";
checkBoxSettings.Properties.ValueType=typeof(string);
}).GetHtml()
@Html.DevExpress().Button(buttonSettings => {
buttonSettings.Name = "Submit";
buttonSettings.Text = "Submit";
buttonSettings.UseSubmitBehavior = true;
}).GetHtml()
}
=========================================>>>>>>>>>>>>>>>>From Action do this <<<<<<<============
[HttpPost]
public ActionResult Index(FormCollection collection)
{
//as if we aceesss CheckBoxExtension.GetValue<Bollean>("includeHistory"); it will not work for unchecked condition and code will throw object refrence not set.
//So to achive unchecked condition of checkbox ,we can collect it using string variable which will have null if not checked
string result = CheckBoxExtension.GetValue<string>("includeHistory");
if (Convert.ToBoolean(result))
{
//Do something
}
else
{
//Do something
}
return View();
}