复选框显示空值不传递给控制器​​mvc

时间:2018-11-29 06:24:53

标签: javascript c# jquery asp.net-mvc razor

我想传递参数值,但是当我单击下载错误时,显示 AllDates 显示空值。 Allstate是一个复选框,用于检查是否获取所有数据(如果未选中),然后将date from和Date放入然后获取值。但是“所有日期”值不会传递给控制器​​并显示空值。任何专家都会告诉我我错了。

我共享错误:

  

参数字典包含参数的空条目   方法的非空类型'System.Boolean'的'AllDates'   'System.Web.Mvc.ActionResult索引(Int32,布尔值,System.String,   System.String)'中   'Lead_Management_System.Controllers.ReportController'。可选的   参数必须是引用类型,可为空的类型,或声明为   可选参数。参数名称:参数

HTML

AUCTIONATOR_PRICE_DATABASE = {
    ["__dbversion"] = 4,
    ["Ragnaros_Horde"] = {
        ["Kraken's Eye of Agility"] = {
            ["mr"] = 6019998,
            ["cc"] = 3,
            ["H2935"] = 6019998,
            ["id"] = "153708:0:0:0:0",
            ["sc"] = 1,
        },
        ["Tidespray Linen Pants of the Harmonious"] = {
            ["mr"] = 2930810,
            ["sc"] = 1,
            ["id"] = "154689:0:0:0:1715",
            ["L2926"] = 2930810,
            ["H2926"] = 19698294,
            ["cc"] = 4,
        },
    },
}

JavaScript

     @using (Html.BeginForm("Index", "Report"))
              {
               <div class="form-control">

               Agent  @Html.DropDownListFor(m => m.agentid, Model.SaleAgentList, new { id = "lblAgent" })


               <div id="lblDate">
                <br />
                Followup Date <br /><br />
                From:  <input type="date" name="cmbSDate" id="cmbSDate" readonly="readonly" />
     To:  <input type="date" name="cmbTDate"  id="cmbTDate" readonly="readonly" />
 Select All : <input type="checkbox" name="AllData" id="AllData" onclick="mcheck()" checked /> <br /> <br />

            </div>

          <input type="submit" value="Download" />

           </div>
           }

控制器

<script type="text/javascript">
    function mcheck() {
        if ($('#AllData').not(':checked').length) {
            document.getElementById("cmbSDate").readOnly = false;
            document.getElementById("cmbTDate").readOnly = false;
            $("#AllData").attr('checked', false);

        }
        else {
            document.getElementById("cmbSDate").readOnly = true;
            document.getElementById("cmbTDate").readOnly = true;
            $("#AllData").attr('checked', true);
        }
    }
</script>

0 个答案:

没有答案