Recently Microsoft has updated the ASP.NET MVC to Beta status, and along with that came code changes. One of the code changes to the IModelBinder and how it interacts with the Parameter bindings broke what I wrote on the last post (utilizing ASP.NET MVC as a JSON Service Provider, and coding the entire web site on the client side).
Upon loading the Beta bits, I realized my AJAX Parameter function was infinite looping. The reason is that the Model Binder defaults to trying to bind Complex Types in the Action Parameter to the form values being passed back, however, since I am not doing a form postback, it could not bind that to the complex type, and could not run the ActionExecuting on the AjaxParameterAttribute I had set.
So to fix this, I thought I would use the IModelBinder and re-do that section of my code using the new bits. Here is the result:
As you can see, I updated the example to be more real world with caching out the original server side object to do compares against the modified version:
I also added 2 new Javascript helpers to test Dates with the Client Side AJAX Templating engine:
And the HTML Code to test Live Binding Dates with the MVC Beta:
Before I change the Live Binding Date using the Microsoft AJAX Client Template:
After I merely type a different date, no post back, it auto converted the string back to the Javascript Date property on my Model Object (notice how the convert and convertBack Live Templates handle the display and changing the javascript object – I have complete control over it):
After post back, testing the IModelBinder to serialize the Javascript Object in JSON to a C# object:
This is just cool. Anyway you slice this, ASP.NET MVC with Microsoft AJAX Client Templating engine is just simple, effective, and elegant. I am falling in love with these frameworks the more and more I play with them.
Questions, comments, opinions?
No comments:
Post a Comment