Posts

Showing posts from December, 2009

Showing Progress of a ASP.NET MVC PartialView

What you’ll need for this recipe: Some long running GET that you really don’t want the rest of the page load to wait for. New ActionResult in a Controller that returns a PartialView. ViewUserControl that will display the results of your long running GET. jQuery and a javascript snippet that will go call your action and load your result. Step 1 – Action Result 1: public ActionResult CreateData( int item) 2: { 3: // Go to your Model/API/Service and get the long running stuff 4: List<String> LargeList = Model.GoGetList(item); 5: 6: // You can either add it to the ViewData or return it.. 7: // Do what you like 8: ViewData.Add( "ElementIdS" , group.ElementIds); 9: 10: // Go return your control.. 11: //it's named the same as you *.ascx file 12: return PartialView( "UserControl"