PDA

View Full Version : extjs datetime format post back to asp.net problem



bryanevil
28 Jun 2010, 11:14 PM
HI all

ASP.net could not deserialize the extjs datetime format in JSON. I think it was a known issue, is there any solution yet?

error from asp.net:

DateTime content '2010-06-29T00:00:00' does not start with '\/Date(' and end with ')\/' as required for JSON.'

Condor
28 Jun 2010, 11:36 PM
What kind of 'post back' are you talking about?

- store save (encoded or json)
- form submit
- own request

wm003
29 Jun 2010, 12:29 AM
You could override the JsonEncode for Dates


Ext.util.JSON.encodeDate = function(d) {
return d.format('M$');
};

krisoye
22 Feb 2011, 5:25 PM
The following was very helpful:

http://www.asp.net/ajaxlibrar/jquery_webforms_serialize_dates_to_json.ashx

I was then able to use JSON.stringifyWcf(data) to serialize the nested JavaScript Date objects into a format that the ASP.NET deserializer would handle:

$.ajax({
type: 'POST',
url: 'MailService.asmx/AccessSaveMerchant',
data: 'data=' + escape(JSON.stringifyWcf(data)),
success: function() {
$(ctrl).remove();
m.IsDirty = false;
},