在控制器的操作中访问DevExpress CheckBox值。 [英] Access DevExpress CheckBox valuein Action Of an Controller.

查看:159
本文介绍了在控制器的操作中访问DevExpress CheckBox值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问DevExpress CheckBox值,即选中或取消选中。在控制器的动作中。

How to access DevExpress CheckBox value i.e Checked Or unchecked. in Action of an controller.

推荐答案

@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();
       }


这篇关于在控制器的操作中访问DevExpress CheckBox值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆