Besides using script or an iframe, is there any way to get independently operating views/actions working on a single page? For example, suppose I have a Delete page for FabWidgets. It might look like:
Are you sure you want to delete this FabWidget "<%= Model.Name %>"?
Careful, this FabWidget controls these FrobNozzles:
<% Html.RenderAction("Grid", "FrobNozzles") %>
<!-- Form for delete/cancel -->
So far so good... unless the FrobNozzle's Grid view is really big and needs to do paging. If the normal paging actions happen, we'll just navigate off the delete page. How can we get the paging for the FrobNozzle's Grid?
I see possibilities in sticking the grid inside an iframe, so it can just render like normal and handle new itself as needed, without messing up the current page. There's also a way using script to do ajax requests and redisplay or whatnot.
Is there any simple ASP.NET MVC integration to make this just work without having to really deal with it much? For example, in ASP.NET WebForms, the ViewState postback would just let us have the FrobNozzle grid fire off events without messing up the rest of the page. Any "magic" like that for ASP.NET MVC?
I did look at partial and so on, but didn't see how it handles the postback issue.
-
This is one of the things that differentiates MVC from WebForms. If you want to do something like this, you'll need to write some code to handle the paging.
You could pass a "PostbackUrl" to the Grid action, and the Grid action could use that Url whenever it pages the data (appending its paging args to the querystring). Or you could pass "PostbackRouteData", which would be a set of route values to use when generating paging links (again, the Grid would add its paging args to the route data).
I would actually suggest using the Ajax helpers here (Ajax.ActionLink would work great for the paging), but if you really need to avoid IFrames and JavaScript, you'll have to roll your own solution.
MVC gives you a lot of control over the rendering, which can be an advantages. However, you lose the "Windows-like" event-driven programming model of WebForms.
MichaelGG : Thanks. I'm not opposed to iframes/ajax, just wondering if they were necessary.
0 comments:
Post a Comment