Tuesday, 29 November 2011

JQuery DatePicker Ajax and MVC RenderAction

So how to do you replicate a MVC Html.RenderAction with JQuery datepicker

I have controller which gives me a daily use data based on a data, I've skipped the boring dal logic with "....." and is shown below.

So I want a default Load which  I can use  Html.RenderAction wrapped in a
with and id of DailyUsage.  So this will only show on a page refresh/load.

 @{ Html.RenderAction("DailyUsage", new { date = DateTime.Now});  }

So I need a Ajax script with the date picker which will update the current table with the selected date. The script below does this by using ajax GET for the controller action.  

 $('#DailyUsage').html(result);   replaces the div contents with the results (partial class) of the controller action. 

Full Code is here

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.