Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to access DevExpress CheckBox value i.e Checked Or unchecked. in Action of an controller.
Posted

1 solution

C#
@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 <<<<<<<============
XML
[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();
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900