asp.net mvc 3 - JSon Date Format issue in MVC -
asp.net-mvc knockout mvc. screen should show empty text box. button. when user clicks button stored date should display in text box.
atm when screen loads date stored in text box '0001-01-01t00:00:00' when press button changes to: /date(1366300981661)/.
anyone have idea why this, , how can display date when button clicked.
please see code below: model
public class clickcountermodel { public void showdates() { firstdate = datetime.now; } }
controller
public class clickcountercontroller : knockoutcontroller { public actionresult showdates(clickcountermodel model) { model.showdates(); return json(model); } }
view
@using perpetuumsoft.knockout @model clickcounter.models.clickcountermodel @{ var ko = html.createknockoutcontext(); } <div>dates: @ko.html.textbox(m => m.firstdate) </div> @ko.html.button("show", "showdates", "clickcounter") @ko.apply(model)
formatting of date missing after results fetched in json format.
jquery
var mydate_string_value = "/date(1366300981661)/"; var value = new date ( parseint(mydate_string_value.replace(/(^.*\()|([+-].*$)/g, '')) ); var dat = value.getmonth() + 1 + "/" + value.getdate() + "/" + value.getfullyear();
Comments
Post a Comment