0
C#を使用するMVCコントローラでhtmlの入力タイプTIMEの値をTimeSpanに変換できません。 Jqueryで入力値を送信しています。HTML入力時刻をTimeSpanに変換します
$scope.AddReg = function() {
AddProduccion();
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: 'http://localhost:2713/Produccion/AgregarProduccion/',
contentType: "application/json; charset=utf-8",
async: true,
//json object to sent to the authentication url
data: JSON.stringify({dp : $scope.materiales, p :$scope.produccion}),
success: function() {
alert("Se agregó registro de produccion");
}
})
};
そして、この操作を行う前に、私はjQueryを使ってそれを送信するためにオブジェクトの配列にNG-モデルをプッシュ:
<div class="row">
<div class="col-md-6">
<label>Hora inicio: </label><input type="time" class="form-control" ng-model="hora.inicioc" />
</div>
<div class="col-md-6">
<label>Hora fin: </label><input type="time" class="form-control" ng-model="hora.finc" />
</div>
</div>
そして、私のjQueryがあります。
var AddProduccion = function() {
$scope.produccion.push(
{
hora_inicio_congelacion: $scope.hora.inicioc,
hora_fin_congelacion: $scope.hora.finc,
hora_inicio_deshielo: $scope.hora.iniciod,
hora_fin_deshielo: $scope.hora.find,
hora_registro: "",
total_producido: 5,
total_merma: 5
}
);
};
そして、私のコントローラはオブジェクトの2つのリストです。私PBolsasModelは、私はすでに、hour_inicio_congelacionを設定する文字列としてhora_fin_congelacionして、自分のを変換しようとしたが、私はビューから取得していた値は持っていないので、私はエラーを得た
public class PBolsasModel
{
public System.TimeSpan hora_inicio_congelacion { get; set; }
public System.TimeSpan hora_fin_congelacion { get; set; }
public System.TimeSpan hora_inicio_deshielo { get; set; }
public System.TimeSpan hora_fin_deshielo { get; set; }
public System.DateTime hora_registro { get; set; }
public double total_producido { get; set; }
public double total_merma { get; set; }
}
ある
[HttpPost]
public ActionResult AgregarProduccion(List<DetalleProduccionBolsasViewModel> dp, List<PBolsasModel> p)
それをTimeSpanに変換する形式。私も泣くようにした。
これらのプロパティの1つにある値は何ですか(例:hora_inicio_congelacion)? – Shyju
"1970-01-01T21:03:00.000Z"この形式の時間 – MisaelGaray