Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Microsoft use <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx" rel="nofollow noreferrer">JavaScriptSerializer</a> to serialize/desirealize the ASP.NET MVC data. If use <code>/Date(utcDate)/</code> format for the <code>Date</code> data type. Try to use</p> <pre><code>'"\\/Date(' + myStory.Deadline.getTime() + ')\\/"' </code></pre> <p>or </p> <pre><code>var d = myStory.Deadline; var dateForMS = '"\\/Date(' + Date.UTC (d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) + ')\\/"' </code></pre> <p>You can also just use <code>Sys.Serialization.JavaScriptSerializer</code> from <code>MicrosoftAjax.js</code> to serialize <code>Deadline</code> or any other <code>Date</code> type.</p> <p><strong>UPDATED</strong>: Probably you should use <code>'\/Date('</code> and <code>')\/'</code> instead of <code>'"\\/Date('</code> and <code>')\\/"'</code>. All depends on where you will insert the string.</p> <p><strong>UPDATED 2</strong>: Now I have it! ASP.NET MVC is used mostly for the posting Form fields per Ajax. On the server side will be just used <code>Parse</code> method for every type to convert the posted parameter to the type. So one can use any string format which are supported by <a href="http://msdn.microsoft.com/en-us/library/1k1skd40.aspx#remarksToggle" rel="nofollow noreferrer">DateTime.Parse</a>. For example you can use ISO 8601 format like '2010-08-29T13:15:00.0000000Z'. To do this in modern browsers (firefox, chrome) one can use <code>toISOString()</code> function. To be more independend one can implement data conversion like described in <a href="http://williamsportwebdeveloper.com/cgi/wp/?p=503" rel="nofollow noreferrer">http://williamsportwebdeveloper.com/cgi/wp/?p=503</a>:</p> <pre><code>var d = new Date($('#story-deadline').val()) //var d = new Date(); // get the date. Here we use just Now. var dAsISOString; if ($.isFunction(d.toISOString)) { //alert("internal toISOString are used!"); dAsISOString = d.toISOString(); } else { dAsISOString = d.getUTCFullYear() + '-' + padzero(d.getUTCMonth() + 1) + '-' + padzero(d.getUTCDate()) + 'T' + padzero(d.getUTCHours()) + ':' + padzero(d.getUTCMinutes()) + ':' + padzero(d.getUTCSeconds())+'.'+ pad2zeros(d.getUTCMilliseconds()) + 'Z'; } var myStory = { Summary: 'Test description', Size: 8, Dedline: dAsISOString }; $.ajax({ url: '/Project/1/AddStory', data: { Summary: myStory.Summary, Size: myStory.Size, Dedline: myStory.Dedline }, dataType: 'json', // ... }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload