dropdown の変更に基づいて、テキストボックスに更新日時を設定する関数があります。
私のJquery:
function ModifymyDiv (element) {
var option = $("#myDiv option:selected").text();
var requrl = '@Url.Action("PopulateConfirmationFields", "Controller", null, Request.Url.Scheme, null)';
$.ajax({
type: "Get",
url: requrl,
success: function (data) {
$('#txtconfTime').empty();
$('#txtconfName').empty();
$('#txtconfName').val(data.name);
$('#txtconfTime').val(data.time);
},
error: function (failure) {
}
});
}
私のJsonメソッド:
public ActionResult PopulateConfirmationFields()
{
User usr = userProxy.GetUserById(UserAppContext.UserOID);
string name = string.Format("{1},{0}", usr.FirstName, usr.LastName);
DateTime time = DateTime.Now;
var t = new { name = name, time = time };
return Json(t, JsonRequestBehavior.AllowGet);
}
まだ私のテキストボックスに...
@Html.TextBoxFor(model => model.confirmationDateTime, new { id = "txtconfTime" })
DateTime 値は次のようになります ...
/Date(1348040819674)/
正しい Datetime Format を TextBox に渡すにはどうすればよいですか? PS文字列に変更することは、この特定のケースではオプションではありません。