Rectangle 27 0

c Simple MVC Question for MVC beginner?

Learning how to leverage HTML helper methods gives you the closest thing to ASP.NET server controls that MVC provides.

The purpose of the helpers is only to assist with the construction of the HTML view. If you're using Ajax, you're probably not going to get away from having to write a reasonable amount of JavaScript, even if it's just to call the appropriate controller action method. My data grid is not Ajax-enabled yet, because I want to make sure it's stable before I start adding the Ajax/jQuery magic.

You could manually construct the partial views in HTML helper methods. However, the feasibility of that approach depends on whether or not the partial views will be reused in other pages. I build a data grid control from scratch using HTML helper methods. Some of my pages have three or four of these data grids managed by a jQuery accordion control to reduce the screen footprint. I chose building an HTML helper for a number of reasons. First, I expected to use this control throughout my applications. Second, I didn't want to burden my views with a bunch of conditional logic. Finally, I wanted to be able to change the grid's configuration (including the model) within the view, so I wouldn't have to recompile every time I changed it. The grid supports both LINQ-to-SQL models and user-defined classes (using reflection), has a built-in pager control and a search mechanism that supports multiple search fields in a grid. I also set up the columns so that they can either display formatted text, link to a controller action or hold a mailto: link. Within the grid itself, you can define the model to populate the grid, optionally set the columns to display, specify the action and controller for creates, and specify a JavaScript function for deletes (because I use the jQuery dialog plugin for confirmation messages). All these changes are managed in the view itself.

neil, that sounds fantastic, let me ask you, are you able to update all of these views that you've generated using custom helpers when one action link is called? ie: user clicks something, and i/u need/want to update several parts of the page, in different areas... yes?

of course just to add, im doing all this in 100% ajax, reloading entire page is just not an option unless a user is moving to a different page.

so if you need to update 4 parts of your page you need to make 4 client-server calls (awch) instead of back in the dreded updatePanel days where you could do it in one call and page lifecycle! ?? oh my god, this is just poor framework design!! as usualy, VS always leaves a bad taste in my mouth once i start getting to know it, should have stuck with webforms!! :(

this is effectively all i want to do without tightly embedding half my business logic in js & the other half scattered around the server, defeating the point of moving to mvc... i just want to do several partial updates at once, like how you'd do with updatePanels, update them all at once during one callback :)