Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在警报中打印ASP.NET MVC的模型值?_Javascript_Jquery_Asp.net Mvc - Fatal编程技术网

Javascript 如何在警报中打印ASP.NET MVC的模型值?

Javascript 如何在警报中打印ASP.NET MVC的模型值?,javascript,jquery,asp.net-mvc,Javascript,Jquery,Asp.net Mvc,我有一个MVC代码,它将日期时间分为两个输入字段,还有一个保存更改的按钮 @model WorkOrderDetailsViewModel <div class="col-sm-3"> <span>Start Date:@Html.TextBoxFor(m => m.StartDateTime, new { @class = "form-control", id="StartDate", @plac

我有一个MVC代码,它将日期时间分为两个输入字段,还有一个保存更改的按钮

@model WorkOrderDetailsViewModel
<div class="col-sm-3">
    <span>Start Date:@Html.TextBoxFor(m => m.StartDateTime, new { @class = "form-control", id="StartDate", @placeholder = "MM/DD/YYYY" })</span>
</div>
<div class="col-sm-3">
    <span>Start Time:@Html.TextBoxFor(m => m.StartDateTime, new { @class = "form-control", id="StartTime", @placeholder = "MM/DD/YYYY" })</span>
</div>

<div class="row">
    <button id="changeDate" class="btn btn-sm btn-primary pull-right">Save Changes</button>
</div>

以下代码将在警报框中显示日期和时间

$("#changeDate").click(function () {

    var startDate = $("#StartDate").val();
    var startTime = $("#StartTime").val();

    alert("Date and time: " + startDate + " - " + startTime )) {
}); 

以下代码将在警报框中显示日期和时间

$("#changeDate").click(function () {

    var startDate = $("#StartDate").val();
    var startTime = $("#StartTime").val();

    alert("Date and time: " + startDate + " - " + startTime )) {
}); 
$("#changeDate").click(function () {
    alert($("#StartDate").val() + " - " +  $("#StartTime").val())
});