Is the MVC Framework poorly prepared for rich page design?

To prefix this question, I decided to take a look at transferring our work to old legacy systems (40+ programs from vb6, vba, vb.net in C # .net) into two separate systems using the same DAL (barcode terminals and one web system) because I spend most of my time fixing irreconcilable or non-existing business logic in 15 year old vba programs. I recently built an entity framework model with full validation and couldn't be happier with it after using it a bit.

A small team is familiar with webform (but not really), but for the last few days I have been researching MVC Razor. I loved the MVC Framework until I tried to add more features to the same page, and then it would be difficult to copy our recent system, which I put in a web form. Previously, I would like to download the client and all its child entities, and then link them to one page for the client, so that they can access everything (exactly what they wanted), it works fine and not slow. On this single page, I could edit all of my account information / contacts / emails / phones / tasks.

All the examples I have done and seen in MVC handle one update, one edit, etc., but of course you cannot separate each action in a new view / page? I can pass a rich model before it is presented in MVC, but then its pain is trying to update all the different child entities.

This is probably the exact design that MVC was not designed for, maybe that's fine, I'm ready to adapt it if MVC becomes the best platform in the future, but how are you going to deal with adding this complexity to? Some methods that I saw:

  • Lots of partial views? passing them baby information (or id and lazy loading)?
  • I have seen methods that wrap several <forms> around everything and handle actions this way.
  • Separate almost all tasks

If the solution is lighter and easier to maintain, I will research everything I need to just want to see at an earlier stage whether I am wasting my time. Any pointers to the right questions I should ask would be greatly appreciated.

+4
source share
2 answers

ASP.NET MVC is no more or less better at handling complex pages than any other technology.

Of course, MVC requires a lower level of operation than the Web Forms application, without support for direct binding, but in most cases it is good and provides much more flexibility in the way your page is displayed.

One of all the ideas of MVC is to give you more control over things, but this control leads to the fact that you need more knowledge and more effort on your part in most non-trivial cases. MVC provides a number of tools to speed up trivial work (for example, creating CRAD from a standard table), but when you have complex models, you will have to do most of the work yourself.

It’s not that MVC is β€œbad” for him, but only this control and flexibility have a compromise with more responsibility on your part.

In your case, you simply create a view model with all the fields you want. Then you create a form to edit these fields. In your controller, you will need to disable this view model and create or update the necessary records in the database. It is not complicated, but it works more than data binding WebForms.

You can explore more advanced (commercial) tools for MVC, such as Telerik tools, which have developed a more interface for data binding, but MVC is not drag-n-drop technology and requires you to connect and write different logic for what is done .

If you need drag-n-drop, databound, then no. MVC is not the right technology. But then WebForms requires you to make many compromises and tie your hands in many ways.

You can use partial views, but I rarely use them. I prefer to use the / DisplayTemplates editor instead, as they take care to correctly name the form fields, even for collections and complex objects. PartialViews tend to have a lot of mistakes if you are not careful. I pretty much use them only as fancy inclusions or when using Ajax.

I'm not sure if you are changing "wrap multiple <forms> around everything". You cannot embed forms in HTML, this is not legal. If you mean placing the form around each row of the table, this is not valid html either in most cases (it is not legal to put the form in the table between the table and tr).

This will help if you have a specific problem that you could ask about, vague objections will not help us solve your problem.

+5
source

You can accomplish anything in MVC that you can use in WebForms. The difference is that MVC usually requires you to write more code, as it does not actually offer you any β€œcontrols” that need to be removed on your page.

In WebForms, it's easy to create a master / detail view with a GridView , FormView , and then wrap everything in an UpdatePanel to automatically support AJAX.

In MVC, while you have helpers such as WebGrid and AjaxHelpers , creating views and / or pages requires a greater understanding of how everything works in order to get the desired functionality. When I start a new MVC project, here I include:

  • Backbone.js - ORM client side that performs CRUD operations against RESTful * APIs
  • Knockout.js - client-side view models and real-time data binding for your views
  • Knockback.js - Wraps Trunk Models in Knockout View Models.

Using these three structures, you can quickly create powerful single-page applications using MVC and WebAPI.

+1
source

All Articles