每次我使用 Internet Explorer(不同版本)运行它时,我的表单中都有几个 datepicker 元素,我收到如下所示的错误:
Unhandled exception at line 393, column 4 in http://localhost/Scripts/bootstrap-datepicker.js
0x800a138f - JavaScript runtime error: Unable to get property 'split' of undefined or null reference
这是包含元素定义的代码,重要的是要提到只有在使用任何 Internet Explorer 版本时按下提交按钮时才会引发错误(它适用于 Firefox):
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Dashboard = "";
ViewBag.Item = "";
ViewBag.Events = "active";
ViewBag.Location = "";
}
<div class="container">
@using (Ajax.BeginForm("EventDetails", new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "eventDetails", InsertionMode = InsertionMode.Replace }))
{
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<input name="equipmentCode" class="form-control" type="text" value="Scan Equipment" onfocus="if(this.value=='Scan Equipment') {this.value = '';}" onblur="if(this.value==''){this.value='Scan Equipment';}" />
<span class="input-group-btn">
<button type="submit" class="btn" onclick="$(this.form).submit();">Submit</button>
</span>
</div>
<p></p>
</div>
</div>
<div class="form-inline">
<div class="row">
<label class="col-lg-3 col-lg-offset-1 text-center" style="padding-top: 7px">Completed Date between:</label>
<div class="col-lg-2"><input name="dtStart" class="form-control datepicker" /></div>
<label class="text-center col-lg-1" style="padding-top: 7px">and:</label>
<div class="col-lg-2"><input name="dtEnd" class="form-control datepicker" /></div>
</div>
</div>
}
<div class="row">
@*<div id="itemDetails" class="col-sm-12"> Commented by Rod*@
<div id="EventDetails" class="col-sm-12">
@RenderBody()
@* @Html.Partial("PartialViews/_Item", Model)*@
</div>
</div>
</div>
这是初始化 datepicker() 的 _Events.cshtml 中的代码:
<script type="text/javascript">
$(function () { $('.datepicker').datepicker();});
</script>
我很感激这里的任何帮助,因为我很想完全删除这个 DatePicker 组件..