I cannot locate the article, but one alternative I read about is to
avoid the date serialization altogether by formatting the date to a
string before sending to the client. then you can easily
var date = new Date(result.DateAsString);
from the json result. or you can plug this into an input element. The
gist of the article was treat Dates like strings instead of dates. it
makes json and js easier to control.

On Jun 22, 12:09 am, John Simons <[email protected]> wrote:
> yeap, I've just checked my code and that is what I'm doing.
> I think you are only left with one option, do not use
> JSONReturnBinderAttribute and do the serialization yourself in the
> action. That is what I ended up doing.
>
> that said you can always contribute a patch or another option is to
> create a suggestion inhttp://castle.uservoice.com
>
> Cheers
> John
>
> On Jun 22, 1:49 pm, Mauricio Scheffer <[email protected]>
> wrote:
>
> > It can't be eval()'ed to a Date object with the default format. Only
> > when the JavaScriptDateTimeConverter is used.
> > Didn't know that json.net supported those attributes, nice tip!
> > However I'd prefer that the return binder could handle that, it would
> > be cleaner IMO...
>
> > On Jun 21, 11:47 pm, John Simons <[email protected]> wrote:
>
> > > Yes you are right you have to do an eval:
> > > $('#txtDate').val(eval(return.Date).toString()); <---- set datetime
> > > value to a text field
>
> > > On Jun 22, 12:28 pm, Mauricio Scheffer <[email protected]>
> > > wrote:
>
> > > > It contains date information, but it's not a Date object. You have to
> > > > parse it and convert it to a Date object in order to use it, unlike
> > > > other types in JSON.
>
> > > > On Jun 21, 10:13 pm, John Simons <[email protected]> wrote:
>
> > > > > Gabriel,
>
> > > > > That is a javascript Date object.
> > > > > If you want to format the date object you can call any on the methods
> > > > > of the javascript Date object, eg:
>
> > > > > Date myDate = new Date(1245531858000-0300);
> > > > > alert(myDate.toString());
>
> > > > > Have a look at this 
> > > > > onehttp://www.w3schools.com/jsref/jsref_obj_date.asp
> > > > > to see what methods the javascript date object has.
>
> > > > > Cheers
> > > > > John
>
> > > > > On Jun 21, 8:06 am, Gabriel Mancini de Campos
>
> > > > > <[email protected]> wrote:
> > > > > > Hi Again Guys,
>
> > > > > > Sorry my flood but i had a trouble, with jquery integration...
> > > > > > In my View i have some like this:
>
> > > > > >  $('#btnList').click(function() {
>
> > > > > >             ajaxOption = $.extend(ajaxOption, {
> > > > > >                 url: 'MyAction.mvc',
> > > > > >                 sucess: function(return) {
> > > > > >                     $('#txtDate').val(return.Date); <---- set 
> > > > > > datetime
> > > > > > value to a text field
> > > > > >                 },
> > > > > >                 type: "Get"
> > > > > >             });
>
> > > > > >             $.ajaxSetup(ajaxOption);
> > > > > >             $.ajax();
> > > > > >         });
>
> > > > > > my Action like this:
>
> > > > > > [AccessibleThrough(Verb.Post)]
> > > > > > [Rescue(typeof(RescueController), "JsonError")]
> > > > > > [return: JSONReturnBinder]
> > > > > > public Customer MyAction() {
> > > > > >    return repository.FindAll()[0];
>
> > > > > > }
>
> > > > > > and the return Json like this:
>
> > > > > > [{"Campanha":"3","Canal":{"Descricao":"Loja","Id":1},"Data":"\/Date
> > > > > > (1245531858000-0300)\/" ,"Numero":"123412","NumeroParcelas":
> > > > > > 5,"PlanoFinanciamento":{"Descricao":"Plano 1","Id":1},"Produto":
> > > > > > {"Descricao":"Mastercard","Id":1}]
>
> > > > > > "Data":"\/Date(1245531858000-0300)\/" <------------- WTF!!!
>
> > > > > > any one knows how i show the true date????
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to