【发布时间】:2014-01-08 01:45:25
【问题描述】:
我正在尝试序列化我的表单我的 PartialViewResult (ASPNET MVC 4) 中有值但是将 DATE 类型字段变为空,有人知道为什么吗?谢谢!
$.ajax({
url: '@Url.Action("CadastroLancamentoParcelar")',
type: 'GET',
cache: false,
context: this,
data: $("#LancamentoForm").serialize(),
success: function (result) {
$(this).html(result);
},
close: function (event, ui) {
$('#dialog-parcelar').empty();
}
});
我的部分视图结果:
[Security]
[HttpGet]
public PartialViewResult CadastroLancamentoParcelar(LancamentoReceitaDespesa lancamento)
{
lancamento.decLancamentoParcelaValor = lancamento.decLancamentoReceitaDespesaValor;
return PartialView("_CadastroLancamentoParcelar", lancamento);
}
HTML MVC:
@Html.TextBoxFor(model => model.dtLancamentoReceitaDespesaDataVencimento, "{0: dd/MM/yyyy}", new { @maxlength = "10", @style = "width:107px;", @onkeypress = "mascara(this,mdata);", autocomplete = "off", @id = "txtCalendario" })
HTML:
<input autocomplete="off" data-val="true" data-val-date="The field Data do Vencimento: must be a date." id="txtCalendario" maxlength="10" name="dtLancamentoReceitaDespesaDataVencimento" onkeypress="mascara(this,mdata);" style="width:107px;" type="text" value="" class="hasDatepicker">
【问题讨论】:
-
检查生成的 HTML,或者在这里发布
-
我的猜测是有一些 ASP.net 代码在干扰。日期选择器可能会创建另一个元素来保存该值,直到提交表单。确保正在更新 HTML 输入。
-
能否发布通过 ajax 请求传递的数据?
-
看起来他在序列化日期值……对吗?和面膜有关系吗? 19%2F12%2F2013
标签: jquery asp.net-mvc-4 jsonserializer